Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions internal/guest/runtime/hcsv2/workload_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ func updateSandboxMounts(sbid string, spec *oci.Spec) error {

_, err := os.Stat(sandboxSource)
if os.IsNotExist(err) {
if err := os.MkdirAll(sandboxSource, 0755); err != nil {
// os.MkdirAll combines the given permissions with the running process's
// umask. By default this causes 0777 to become 0755.
// Temporarily set the umask of this process to 0 so that we can actually
// make all dirs with os.ModePerm permissions.
savedUmask := unix.Umask(0)
Comment thread
katiewasnothere marked this conversation as resolved.
defer unix.Umask(savedUmask)
if err := os.MkdirAll(sandboxSource, os.ModePerm); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not reset the umask if MkdirAll returns non-nil error. Can we change this to something like:

savedumask := unix.Umask(0)
defer unix.Umask(savedUmask)
err := os.MkdirAll(...)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

return err
}
}
Expand Down Expand Up @@ -68,7 +74,13 @@ func updateHugePageMounts(sbid string, spec *oci.Spec) error {

_, err := os.Stat(hugePageMountSource)
if os.IsNotExist(err) {
if err := os.MkdirAll(hugePageMountSource, 0755); err != nil {
// os.MkdirAll combines the given permissions with the running process's
// umask. By default this causes 0777 to become 0755.
// Temporarily set the umask of this process to 0 so that we can actually
// make all dirs with os.ModePerm permissions.
savedUmask := unix.Umask(0)
defer unix.Umask(savedUmask)
if err := os.MkdirAll(hugePageMountSource, os.ModePerm); err != nil {
return err
}

Expand Down