diff options
Diffstat (limited to 'hst')
| -rw-r--r-- | hst/config_test.go | 26 | ||||
| -rw-r--r-- | hst/fsbind.go | 13 | ||||
| -rw-r--r-- | hst/hst.go | 24 |
3 files changed, 32 insertions, 31 deletions
diff --git a/hst/config_test.go b/hst/config_test.go index f57be3dc..ea50d4f1 100644 --- a/hst/config_test.go +++ b/hst/config_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "hakurei.app/container" + "hakurei.app/container/fhs" "hakurei.app/hst" ) @@ -25,18 +25,18 @@ func TestConfigValidate(t *testing.T) { {"home", &hst.Config{Container: &hst.ContainerConfig{}}, &hst.AppError{Step: "validate configuration", Err: hst.ErrConfigNull, Msg: "container configuration missing path to home directory"}}, {"shell", &hst.Config{Container: &hst.ContainerConfig{ - Home: container.AbsFHSTmp, + Home: fhs.AbsTmp, }}, &hst.AppError{Step: "validate configuration", Err: hst.ErrConfigNull, Msg: "container configuration missing path to shell"}}, {"path", &hst.Config{Container: &hst.ContainerConfig{ - Home: container.AbsFHSTmp, - Shell: container.AbsFHSTmp, + Home: fhs.AbsTmp, + Shell: fhs.AbsTmp, }}, &hst.AppError{Step: "validate configuration", Err: hst.ErrConfigNull, Msg: "container configuration missing path to initial program"}}, {"valid", &hst.Config{Container: &hst.ContainerConfig{ - Home: container.AbsFHSTmp, - Shell: container.AbsFHSTmp, - Path: container.AbsFHSTmp, + Home: fhs.AbsTmp, + Shell: fhs.AbsTmp, + Path: fhs.AbsTmp, }}, nil}, } for _, tc := range testCases { @@ -56,14 +56,14 @@ func TestExtraPermConfig(t *testing.T) { }{ {"nil", nil, "<invalid>"}, {"nil path", &hst.ExtraPermConfig{Path: nil}, "<invalid>"}, - {"r", &hst.ExtraPermConfig{Path: container.AbsFHSRoot, Read: true}, "r--:/"}, - {"r+", &hst.ExtraPermConfig{Ensure: true, Path: container.AbsFHSRoot, Read: true}, "r--+:/"}, + {"r", &hst.ExtraPermConfig{Path: fhs.AbsRoot, Read: true}, "r--:/"}, + {"r+", &hst.ExtraPermConfig{Ensure: true, Path: fhs.AbsRoot, Read: true}, "r--+:/"}, {"w", &hst.ExtraPermConfig{Path: hst.AbsTmp, Write: true}, "-w-:/.hakurei"}, {"w+", &hst.ExtraPermConfig{Ensure: true, Path: hst.AbsTmp, Write: true}, "-w-+:/.hakurei"}, - {"x", &hst.ExtraPermConfig{Path: container.AbsFHSRunUser, Execute: true}, "--x:/run/user/"}, - {"x+", &hst.ExtraPermConfig{Ensure: true, Path: container.AbsFHSRunUser, Execute: true}, "--x+:/run/user/"}, - {"rwx", &hst.ExtraPermConfig{Path: container.AbsFHSTmp, Read: true, Write: true, Execute: true}, "rwx:/tmp/"}, - {"rwx+", &hst.ExtraPermConfig{Ensure: true, Path: container.AbsFHSTmp, Read: true, Write: true, Execute: true}, "rwx+:/tmp/"}, + {"x", &hst.ExtraPermConfig{Path: fhs.AbsRunUser, Execute: true}, "--x:/run/user/"}, + {"x+", &hst.ExtraPermConfig{Ensure: true, Path: fhs.AbsRunUser, Execute: true}, "--x+:/run/user/"}, + {"rwx", &hst.ExtraPermConfig{Path: fhs.AbsTmp, Read: true, Write: true, Execute: true}, "rwx:/tmp/"}, + {"rwx+", &hst.ExtraPermConfig{Ensure: true, Path: fhs.AbsTmp, Read: true, Write: true, Execute: true}, "rwx+:/tmp/"}, } for _, tc := range testCases { diff --git a/hst/fsbind.go b/hst/fsbind.go index 2cebf6b6..8b7b5fe8 100644 --- a/hst/fsbind.go +++ b/hst/fsbind.go @@ -6,6 +6,7 @@ import ( "hakurei.app/container" "hakurei.app/container/check" + "hakurei.app/container/fhs" ) func init() { gob.Register(new(FSBind)) } @@ -29,19 +30,19 @@ type FSBind struct { Optional bool `json:"optional,omitempty"` // enable special behaviour: - // for autoroot, Target must be set to [container.AbsFHSRoot]; - // for autoetc, Target must be set to [container.AbsFHSEtc] + // for autoroot, Target must be set to [fhs.AbsRoot]; + // for autoetc, Target must be set to [fhs.AbsEtc] Special bool `json:"special,omitempty"` } // IsAutoRoot returns whether this FSBind has autoroot behaviour enabled. func (b *FSBind) IsAutoRoot() bool { - return b.Valid() && b.Special && b.Target.String() == container.FHSRoot + return b.Valid() && b.Special && b.Target.String() == fhs.Root } // IsAutoEtc returns whether this FSBind has autoetc behaviour enabled. func (b *FSBind) IsAutoEtc() bool { - return b.Valid() && b.Special && b.Target.String() == container.FHSEtc + return b.Valid() && b.Special && b.Target.String() == fhs.Etc } func (b *FSBind) Valid() bool { @@ -56,7 +57,7 @@ func (b *FSBind) Valid() bool { return false } else { switch b.Target.String() { - case container.FHSRoot, container.FHSEtc: + case fhs.Root, fhs.Etc: break default: @@ -138,7 +139,7 @@ func (b *FSBind) String() string { if flagSym != "" { prefix += ":" + flagSym } - if b.Source.String() != container.FHSRoot { + if b.Source.String() != fhs.Root { return prefix + ":" + b.Source.String() } return prefix @@ -6,8 +6,8 @@ import ( "net" "os" - "hakurei.app/container" "hakurei.app/container/check" + "hakurei.app/container/fhs" ) // An AppError is returned while starting an app according to [hst.Config]. @@ -85,8 +85,8 @@ func Template() *Config { DirectWayland: false, ExtraPerms: []*ExtraPermConfig{ - {Path: container.AbsFHSVarLib.Append("hakurei/u0"), Ensure: true, Execute: true}, - {Path: container.AbsFHSVarLib.Append("hakurei/u0/org.chromium.Chromium"), Read: true, Write: true, Execute: true}, + {Path: fhs.AbsVarLib.Append("hakurei/u0"), Ensure: true, Execute: true}, + {Path: fhs.AbsVarLib.Append("hakurei/u0/org.chromium.Chromium"), Read: true, Write: true, Execute: true}, }, Identity: 9, @@ -112,9 +112,9 @@ func Template() *Config { "GOOGLE_DEFAULT_CLIENT_SECRET": "OTJgUOQcT7lO7GsGZq2G4IlT", }, Filesystem: []FilesystemConfigJSON{ - {&FSBind{Target: container.AbsFHSRoot, Source: container.AbsFHSVarLib.Append("hakurei/base/org.debian"), Write: true, Special: true}}, - {&FSBind{Target: container.AbsFHSEtc, Source: container.AbsFHSEtc, Special: true}}, - {&FSEphemeral{Target: container.AbsFHSTmp, Write: true, Perm: 0755}}, + {&FSBind{Target: fhs.AbsRoot, Source: fhs.AbsVarLib.Append("hakurei/base/org.debian"), Write: true, Special: true}}, + {&FSBind{Target: fhs.AbsEtc, Source: fhs.AbsEtc, Special: true}}, + {&FSEphemeral{Target: fhs.AbsTmp, Write: true, Perm: 0755}}, {&FSOverlay{ Target: check.MustAbs("/nix/store"), Lower: []*check.Absolute{check.MustAbs("/mnt-root/nix/.ro-store")}, @@ -122,18 +122,18 @@ func Template() *Config { Work: check.MustAbs("/mnt-root/nix/.rw-store/work"), }}, {&FSBind{Source: check.MustAbs("/nix/store")}}, - {&FSLink{Target: container.AbsFHSRun.Append("current-system"), Linkname: "/run/current-system", Dereference: true}}, - {&FSLink{Target: container.AbsFHSRun.Append("opengl-driver"), Linkname: "/run/opengl-driver", Dereference: true}}, - {&FSBind{Source: container.AbsFHSVarLib.Append("hakurei/u0/org.chromium.Chromium"), + {&FSLink{Target: fhs.AbsRun.Append("current-system"), Linkname: "/run/current-system", Dereference: true}}, + {&FSLink{Target: fhs.AbsRun.Append("opengl-driver"), Linkname: "/run/opengl-driver", Dereference: true}}, + {&FSBind{Source: fhs.AbsVarLib.Append("hakurei/u0/org.chromium.Chromium"), Target: check.MustAbs("/data/data/org.chromium.Chromium"), Write: true, Ensure: true}}, - {&FSBind{Source: container.AbsFHSDev.Append("dri"), Device: true, Optional: true}}, + {&FSBind{Source: fhs.AbsDev.Append("dri"), Device: true, Optional: true}}, }, Username: "chronos", - Shell: container.AbsFHSRun.Append("current-system/sw/bin/zsh"), + Shell: fhs.AbsRun.Append("current-system/sw/bin/zsh"), Home: check.MustAbs("/data/data/org.chromium.Chromium"), - Path: container.AbsFHSRun.Append("current-system/sw/bin/chromium"), + Path: fhs.AbsRun.Append("current-system/sw/bin/chromium"), Args: []string{ "chromium", "--ignore-gpu-blocklist", |
