From 1438096339f49bdd466f3b057c7e695aa126fc3c Mon Sep 17 00:00:00 2001 From: Ophestra Date: Mon, 25 Aug 2025 17:51:08 +0900 Subject: hst/config: handle filesystem entry targeting root This allows any fstype supported by hst to be directly mounted on sysroot. A special case in internal/app applies the matching entry early and excludes it from path hiding. Closes #5. Signed-off-by: Ophestra --- hst/config.go | 9 ++------- hst/hst.go | 9 ++++----- hst/hst_test.go | 9 +++++++-- 3 files changed, 13 insertions(+), 14 deletions(-) (limited to 'hst') diff --git a/hst/config.go b/hst/config.go index 8226a35f..e2f95d14 100644 --- a/hst/config.go +++ b/hst/config.go @@ -93,17 +93,12 @@ type ( // pass through all devices Device bool `json:"device,omitempty"` - // container mount points + // container mount points; + // if the first element targets /, it is inserted early and excluded from path hiding Filesystem []FilesystemConfigJSON `json:"filesystem"` // create symlinks inside container filesystem Link []LinkConfig `json:"symlink"` - // automatically bind mount top-level directories to container root; - // the zero value disables this behaviour - AutoRoot *container.Absolute `json:"auto_root,omitempty"` - // extra flags for AutoRoot - RootFlags int `json:"root_flags,omitempty"` - // read-only /etc directory Etc *container.Absolute `json:"etc,omitempty"` // automatically set up /etc symlinks diff --git a/hst/hst.go b/hst/hst.go index 6e77dc98..6654a4b7 100644 --- a/hst/hst.go +++ b/hst/hst.go @@ -97,6 +97,7 @@ func Template() *Config { "GOOGLE_DEFAULT_CLIENT_SECRET": "OTJgUOQcT7lO7GsGZq2G4IlT", }, Filesystem: []FilesystemConfigJSON{ + {&FSBind{container.AbsFHSRoot, container.AbsFHSVarLib.Append("hakurei/base/org.debian"), true, false, false, true}}, {&FSEphemeral{Target: container.AbsFHSTmp, Write: true, Perm: 0755}}, {&FSOverlay{ Target: container.MustAbs("/nix/store"), @@ -111,11 +112,9 @@ func Template() *Config { Target: container.MustAbs("/data/data/org.chromium.Chromium"), Write: true}}, {&FSBind{Source: container.AbsFHSDev.Append("dri"), Device: true, Optional: true}}, }, - Link: []LinkConfig{{container.AbsFHSRunUser.Append("65534"), container.FHSRunUser + "150"}}, - AutoRoot: container.AbsFHSVarLib.Append("hakurei/base/org.debian"), - RootFlags: container.BindWritable, - Etc: container.AbsFHSEtc, - AutoEtc: true, + Link: []LinkConfig{{container.AbsFHSRunUser.Append("65534"), container.FHSRunUser + "150"}}, + Etc: container.AbsFHSEtc, + AutoEtc: true, }, } } diff --git a/hst/hst_test.go b/hst/hst_test.go index a3930f48..b8ec79c9 100644 --- a/hst/hst_test.go +++ b/hst/hst_test.go @@ -102,6 +102,13 @@ func TestTemplate(t *testing.T) { "map_real_uid": true, "device": true, "filesystem": [ + { + "type": "bind", + "dst": "/", + "src": "/var/lib/hakurei/base/org.debian", + "write": true, + "autoroot": true + }, { "type": "ephemeral", "dst": "/tmp/", @@ -148,8 +155,6 @@ func TestTemplate(t *testing.T) { "linkname": "/run/user/150" } ], - "auto_root": "/var/lib/hakurei/base/org.debian", - "root_flags": 2, "etc": "/etc/", "auto_etc": true } -- cgit v1.3.1