Skip to content

Commit

Permalink
Fix Windows service panic file to not be read-only
Browse files Browse the repository at this point in the history
Go 1.14 introduced a change to os.OpenFile (and syscall.Open) on Windows
that uses the permissions passed to determine if the file should be
created read-only or not. If the user-write bit (0200) is not set, then
FILE_ATTRIBUTE_READONLY is set on the underlying CreateFile call.

This is a significant change for any Windows code which created new
files and set the permissions to 0 (previously the permissions had no
affect, so some code didn't set them at all).

This change fixes the issue for the Windows service panic file. It will
now properly be created as a non-read-only file on Go 1.14+.

I have looked over the rest of the containerd code and didn't see other
places where this seems like an issue.

Signed-off-by: Kevin Parsons <kevpar@microsoft.com>
(cherry picked from commit b2420eb)
Signed-off-by: Derek McGowan <derek@mcg.dev>
  • Loading branch information
kevpar authored and dmcgowan committed Nov 25, 2020
1 parent 9c24574 commit c0f1add
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/containerd/command/service_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ Loop:

func initPanicFile(path string) error {
var err error
panicFile, err = os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0)
panicFile, err = os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
if err != nil {
return err
}
Expand Down

0 comments on commit c0f1add

Please sign in to comment.