detached ed21f4f

fix(vm): create the jailer chroot base directory

Jailer 1.17 canonicalizes --chroot-base-dir and exits with 'Failed to
canonicalize path' when it does not exist, so every jailed VM failed to
boot on a fresh state directory. Create <state>/jail (0700) at driver
start. Found running the VM integration tests with the jailer as root.
commit
ed21f4fd1e3a994feba33bbdd2899648e63ec823
author
brice · · 2026-10-12 21:09 UTC
parent
e917abe
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +22 -0
M internal/sandbox/vm/driver.go +5 -0
@@ -121,6 +121,11 @@ func New(ctx context.Context, cfg sandbox.Config, opt Options) (*Driver, error)
121121 fail := func(err error) (*Driver, error) { _ = d.Close(); return nil, err }
122122
123123 if !cfg.JailerOff {
124+ // Jailer 1.17 canonicalizes --chroot-base-dir and fails when it does not
125+ // exist ("Failed to canonicalize path"); older releases created it.
126+ if err := os.MkdirAll(jailBase(cfg.StateDir), 0o700); err != nil {
127+ return fail(fmt.Errorf("jailer chroot base: %w", err))
128+ }
124129 for _, p := range []string{cfg.KernelPath(), cfg.BaseImagePath()} {
125130 if err := checkWorldReadable(p); err != nil {
126131 return fail(err)
@@ -121,6 +121,11 @@ func New(ctx context.Context, cfg sandbox.Config, opt Options) (*Driver, error)
121 fail := func(err error) (*Driver, error) { _ = d.Close(); return nil, err }121 fail := func(err error) (*Driver, error) { _ = d.Close(); return nil, err }
122 122
123 if !cfg.JailerOff {123 if !cfg.JailerOff {
124+ // Jailer 1.17 canonicalizes --chroot-base-dir and fails when it does not
125+ // exist ("Failed to canonicalize path"); older releases created it.
126+ if err := os.MkdirAll(jailBase(cfg.StateDir), 0o700); err != nil {
127+ return fail(fmt.Errorf("jailer chroot base: %w", err))
128+ }
124 for _, p := range []string{cfg.KernelPath(), cfg.BaseImagePath()} {129 for _, p := range []string{cfg.KernelPath(), cfg.BaseImagePath()} {
125 if err := checkWorldReadable(p); err != nil {130 if err := checkWorldReadable(p); err != nil {
126 return fail(err)131 return fail(err)
M internal/sandbox/vm/vm_test.go +17 -0
@@ -1022,3 +1022,20 @@ func TestRemoveCgroup(t *testing.T) {
10221022 t.Fatal("a non-empty cgroup cannot be removed and must be reported")
10231023 }
10241024 }
1025+
1026+// Jailer 1.17 canonicalizes --chroot-base-dir and exits when it does not exist:
1027+// the driver must create it (seen on a real host, invisible with the jailer off).
1028+func TestNewCreatesTheJailerChrootBase(t *testing.T) {
1029+ e := newEnv(t, "ok")
1030+ e.cfg.JailerOff = false
1031+ e.cfg.Jailer = e.cfg.Firecracker // any executable: it is only resolved here
1032+ d, err := New(context.Background(), e.cfg, Options{Run: e.run, Net: e.plumb, BootTimeout: 5 * time.Second})
1033+ if err != nil {
1034+ t.Fatal(err)
1035+ }
1036+ defer func() { _ = d.Close() }()
1037+ st, err := os.Stat(jailBase(e.cfg.StateDir))
1038+ if err != nil || !st.IsDir() {
1039+ t.Fatalf("jail base not created: %v", err)
1040+ }
1041+}
@@ -1022,3 +1022,20 @@ func TestRemoveCgroup(t *testing.T) {
1022 t.Fatal("a non-empty cgroup cannot be removed and must be reported")1022 t.Fatal("a non-empty cgroup cannot be removed and must be reported")
1023 }1023 }
1024 }1024 }
1025+
1026+// Jailer 1.17 canonicalizes --chroot-base-dir and exits when it does not exist:
1027+// the driver must create it (seen on a real host, invisible with the jailer off).
1028+func TestNewCreatesTheJailerChrootBase(t *testing.T) {
1029+ e := newEnv(t, "ok")
1030+ e.cfg.JailerOff = false
1031+ e.cfg.Jailer = e.cfg.Firecracker // any executable: it is only resolved here
1032+ d, err := New(context.Background(), e.cfg, Options{Run: e.run, Net: e.plumb, BootTimeout: 5 * time.Second})
1033+ if err != nil {
1034+ t.Fatal(err)
1035+ }
1036+ defer func() { _ = d.Close() }()
1037+ st, err := os.Stat(jailBase(e.cfg.StateDir))
1038+ if err != nil || !st.IsDir() {
1039+ t.Fatalf("jail base not created: %v", err)
1040+ }
1041+}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 4

Tags 11

↑↓ moveenter openesc close