Skip to content

Commit feca626

Browse files
committed
BUGFIX: chown using the full path instead of the relative path
Signed-off-by: Tim Ramlot <[email protected]>
1 parent c552f3a commit feca626

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

storage/filesystem.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,17 @@ func (f *Filesystem) WriteFiles(meta metadata.Metadata, files map[string][]byte)
263263
return nil
264264
}
265265

266-
// If a fsGroup is defined, Chown all files in the timestamped directory.
266+
// Change ownership of the data directory, the timestamp directory and all files within it.
267+
paths := []string{
268+
filepath.Join(f.dataPathForVolumeID(meta.VolumeID), tsDirName),
269+
}
267270
for filename := range files {
268-
// Set the uid to -1 which means don't change ownership in Go.
269-
if err := os.Chown(filepath.Join(tsDirName, filename), -1, int(*fsGroup)); err != nil {
270-
return err
271+
paths = append(paths, filepath.Join(f.dataPathForVolumeID(meta.VolumeID), tsDirName, filename))
272+
}
273+
274+
for _, path := range paths {
275+
if err := os.Lchown(path, -1, int(*fsGroup)); err != nil {
276+
return fmt.Errorf("failed to chown data dir to gid %v: %w", *fsGroup, err)
271277
}
272278
}
273279

0 commit comments

Comments
 (0)