Skip to content

Commit 560f64f

Browse files
committed
native: set '/' permission to 0755
Unlike other snapshotters, the permission was previously set to 0700 unexpectedly. Signed-off-by: Akihiro Suda <[email protected]>
1 parent c938bbb commit 560f64f

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

snapshots/native/native.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k
251251
if err != nil {
252252
return nil, errors.Wrap(err, "failed to create temp dir")
253253
}
254+
if err := os.Chmod(td, 0755); err != nil {
255+
return nil, errors.Wrapf(err, "failed to chmod %s to 0755", td)
256+
}
254257
defer func() {
255258
if err != nil {
256259
if td != "" {

snapshots/testsuite/testsuite.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func SnapshotterSuite(t *testing.T, name string, snapshotterFn func(ctx context.
6262

6363
t.Run("StatInWalk", makeTest(name, snapshotterFn, checkStatInWalk))
6464
t.Run("CloseTwice", makeTest(name, snapshotterFn, closeTwice))
65+
t.Run("RootPermission", makeTest(name, snapshotterFn, checkRootPermission))
6566
}
6667

6768
func makeTest(name string, snapshotterFn func(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error), fn func(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string)) func(t *testing.T) {
@@ -842,3 +843,18 @@ func closeTwice(ctx context.Context, t *testing.T, snapshotter snapshots.Snapsho
842843
t.Fatalf("The second close failed: %+v", err)
843844
}
844845
}
846+
847+
func checkRootPermission(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) {
848+
preparing, err := snapshotterPrepareMount(ctx, snapshotter, "preparing", "", work)
849+
if err != nil {
850+
t.Fatal(err)
851+
}
852+
defer testutil.Unmount(t, preparing)
853+
st, err := os.Stat(preparing)
854+
if err != nil {
855+
t.Fatal(err)
856+
}
857+
if mode := st.Mode() & 0777; mode != 0755 {
858+
t.Fatalf("expected 0755, got 0%o", mode)
859+
}
860+
}

0 commit comments

Comments
 (0)