Skip to content

Commit 92d147e

Browse files
authored
Merge pull request #2485 from AkihiroSuda/fix-native-root-permission
native: set '/' permission to 0755
2 parents 0d52c71 + 7461739 commit 92d147e

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) {
@@ -844,3 +845,18 @@ func closeTwice(ctx context.Context, t *testing.T, snapshotter snapshots.Snapsho
844845
t.Fatalf("The second close failed: %+v", err)
845846
}
846847
}
848+
849+
func checkRootPermission(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) {
850+
preparing, err := snapshotterPrepareMount(ctx, snapshotter, "preparing", "", work)
851+
if err != nil {
852+
t.Fatal(err)
853+
}
854+
defer testutil.Unmount(t, preparing)
855+
st, err := os.Stat(preparing)
856+
if err != nil {
857+
t.Fatal(err)
858+
}
859+
if mode := st.Mode() & 0777; mode != 0755 {
860+
t.Fatalf("expected 0755, got 0%o", mode)
861+
}
862+
}

0 commit comments

Comments
 (0)