Skip to content

Commit

Permalink
Merge pull request kubernetes#826 from openshift-cherrypick-robot/che…
Browse files Browse the repository at this point in the history
…rry-pick-804-to-release-4.7

[release-4.7] Bug 1975553: only chown if non-windows machine with projected volumes
  • Loading branch information
openshift-merge-robot authored Jun 30, 2021
2 parents 87cc9a4 + cd34728 commit d0b1ad4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/volume/util/atomic_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ func (w *AtomicWriter) newTimestampDir() (string, error) {
// writePayloadToDir writes the given payload to the given directory. The
// directory must exist.
func (w *AtomicWriter) writePayloadToDir(payload map[string]FileProjection, dir string) error {
isNotWindows := runtime.GOOS != "windows"
for userVisiblePath, fileProjection := range payload {
content := fileProjection.Data
mode := os.FileMode(fileProjection.Mode)
Expand Down Expand Up @@ -400,9 +401,11 @@ func (w *AtomicWriter) writePayloadToDir(payload map[string]FileProjection, dir
if fileProjection.FsUser == nil {
continue
}
if err := os.Chown(fullPath, int(*fileProjection.FsUser), -1); err != nil {
klog.Errorf("%s: unable to change file %s with owner %v: %v", w.logContext, fullPath, int(*fileProjection.FsUser), err)
return err
if isNotWindows {
if err := os.Chown(fullPath, int(*fileProjection.FsUser), -1); err != nil {
klog.Errorf("%s: unable to change file %s with owner %v: %v", w.logContext, fullPath, int(*fileProjection.FsUser), err)
return err
}
}
}

Expand Down

0 comments on commit d0b1ad4

Please sign in to comment.