fix: Block creating files with non-existing parent directories using O_CREATE

This commit is contained in:
Felicitas Pojtinger
2022-01-12 22:39:00 +01:00
parent 5ed0eec75e
commit 3a0165895a
3 changed files with 34 additions and 20 deletions

View File

@@ -1114,15 +1114,14 @@ var openFileTests = []struct {
func(f afero.File) error { return nil },
false,
},
// FIXME: STFS can create file in non-existent directory, which should not be possible
// {
// "Can not open /mydir/test.txt if O_CREATE is set",
// openFileArgs{"/mydir/test.txt", os.O_CREATE, os.ModePerm},
// true,
// func(f afero.Fs) error { return nil },
// func(f afero.File) error { return nil },
// false,
// },
{
"Can not open /mydir/test.txt if O_CREATE is set",
openFileArgs{"/mydir/test.txt", os.O_CREATE, os.ModePerm},
true,
func(f afero.Fs) error { return nil },
func(f afero.File) error { return nil },
false,
},
{
"Can open /mydir/test.txt after creating it",
openFileArgs{"/mydir/test.txt", os.O_RDONLY, 0},