@@ -64,7 +64,7 @@ func createTmpfs(monRootfs string, path string, flags uint64, mode string, size
6464
6565 if mode == "1777" {
6666 // sonarcloud:go:S2612 -- This is a tmpfs mount point, sticky bit 1777 is required (like /tmp), controlled path, safe by design
67- err := os .Chmod (dstPath , 01777 ) // NOSONAR
67+ err := os .Chmod (path , 01777 ) // NOSONAR
6868 if err != nil {
6969 return fmt .Errorf ("failed to chmod %s: %w" , path , err )
7070 }
@@ -116,23 +116,6 @@ func setupDev(monRootfs string, devPath string) error {
116116 // Create the new device node
117117 err = unix .Mknod (dstPath , devStat .Mode , int (newDev )) //nolint: gosec
118118 if err != nil {
119- // If mknod fails because of permissions (e.g. in a container), try to bind mount it
120- if errors .Is (err , unix .EPERM ) || errors .Is (err , unix .EACCES ) {
121- uniklog .Warnf ("failed to make device node %s: %v. Fallback to bind mount." , dstPath , err )
122- // Create an empty file to be used as mount point
123- f , err1 := os .Create (dstPath )
124- if err1 != nil && ! os .IsExist (err1 ) {
125- return fmt .Errorf ("failed to create mount point for device %s: %w" , dstPath , err1 )
126- }
127- if f != nil {
128- f .Close ()
129- }
130- err = unix .Mount (devPath , dstPath , "" , unix .MS_BIND , "" )
131- if err != nil {
132- return fmt .Errorf ("failed to bind mount device %s: %w" , devPath , err )
133- }
134- return nil
135- }
136119 return fmt .Errorf ("failed to make device node %s: %w" , dstPath , err )
137120 }
138121
@@ -196,13 +179,7 @@ func fileFromHost(monRootfs string, hostPath string, target string, mFlags int,
196179 }
197180 }
198181 } else {
199- if withCopy {
200- return ErrCopyDir
201- }
202- err = bindMountFile (hostPath , dstPath , "" , 0 , mFlags , true )
203- if err != nil {
204- return fmt .Errorf ("failed to bind mount file %s: %w" , hostPath , err )
205- }
182+ return ErrCopyDir
206183 }
207184
208185 if withCopy {
0 commit comments