@@ -23,7 +23,6 @@ import (
2323 "context"
2424 "fmt"
2525 "os"
26- "runtime"
2726 "strconv"
2827 "strings"
2928
@@ -260,33 +259,15 @@ func (d *nodeService) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol
260259 sourceVolumeHostPath = strings .TrimPrefix (target , EBSPathPrefix )
261260 }
262261
263- // chown/chmod don't work on Windows
264- if runtime .GOOS != "windows" {
265- // Gid is generated based on SourceVolumeHostPath
266- gid := util .GenerateGIDFromPath (sourceVolumeHostPath )
267- // Set permissions on the mount point to allow non-root users to access it
268- if err := setMountPointPermissions (target , gid ); err != nil {
269- return nil , status .Errorf (codes .Internal , "Failed to set permissions on mount point %s: %v" , target , err )
270- }
271- klog .V (4 ).InfoS ("Successfully set permissions on mount point" , "target" , target , "volumeID" , volumeID , "gid" , gid )
272- }
273-
274- return & csi.NodeStageVolumeResponse {}, nil
275- }
276-
277- // setMountPointPermissions sets the permissions on the mount point to allow non-root users to access it
278- func setMountPointPermissions (mountPath string , gid int ) error {
279- // Change group ownership to the provided GID
280- if err := chownFunc (mountPath , - 1 , gid ); err != nil {
281- return fmt .Errorf ("failed to change group ownership of %s to GID %d: %v" , mountPath , gid , err )
282- }
262+ // Gid is generated based on SourceVolumeHostPath
263+ gid := util .GenerateGIDFromPath (sourceVolumeHostPath )
283264
284- // Set permissions to 0775 with setgid bit
285- if err := chmodFunc ( mountPath , 0775 | os . ModeSetgid ); err != nil {
286- return fmt .Errorf ("failed to set permissions on %s: %v" , mountPath , err )
265+ // Set permissions on the mount point to allow non-root users to access it
266+ if err := setMountPointPermissions ( target , gid , volumeID ); err != nil {
267+ return nil , status .Errorf (codes . Internal , "Failed to set permissions on mount point %s: %v" , target , err )
287268 }
288269
289- return nil
270+ return & csi. NodeStageVolumeResponse {}, nil
290271}
291272
292273func newNodeService () nodeService {
0 commit comments