You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The function ReplaceFiles in nginx/file/manager.go creates files by internally calling os.Create, which, by default, creates files with mode 0666 (before applying umask). See the source code of os.Create for more details.
The function writeFile changes the mode of secret files to 0640 by calling chmod, but does nothing for regular files. Hence, the check Expect(info.Mode()).To(Equal(os.FileMode(0o644))) in nginx/file/manager_test.go only passes for umask with specific values.
In my environment, the umask value is 002. Therefore, the mode for regular files will be 0666 - 0002 = 0664, causing the unit test to fail. In the following screenshot, 420 is 0o644, and 436 is 0o664.
To Reproduce
Step 1: Set umask to 002.
Step 2: Run make unit-test.
The text was updated successfully, but these errors were encountered:
Describe the bug
As shown in the following code snippet, the function
ensureFiles
checks the file mode for both regular files and secret files.nginx-gateway-fabric/internal/mode/static/nginx/file/manager_test.go
Lines 43 to 47 in 6d4cfd7
The function
ReplaceFiles
innginx/file/manager.go
creates files by internally calling os.Create, which, by default, creates files with mode 0666 (before applyingumask
). See the source code ofos.Create
for more details.The function
writeFile
changes the mode of secret files to 0640 by callingchmod
, but does nothing for regular files. Hence, the checkExpect(info.Mode()).To(Equal(os.FileMode(0o644)))
innginx/file/manager_test.go
only passes forumask
with specific values.In my environment, the
umask
value is 002. Therefore, the mode for regular files will be 0666 - 0002 = 0664, causing the unit test to fail. In the following screenshot, 420 is 0o644, and 436 is 0o664.To Reproduce
umask
to 002.make unit-test
.The text was updated successfully, but these errors were encountered: