github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/pkg/archive/diff_unix.go (about) 1 //go:build !windows 2 // +build !windows 3 4 package archive 5 6 import "golang.org/x/sys/unix" 7 8 // overrideUmask sets current process's file mode creation mask to newmask 9 // and returns a function to restore it. 10 // 11 // WARNING for readers stumbling upon this code. Changing umask in a multi- 12 // threaded environment isn't safe. Don't use this without understanding the 13 // risks, and don't export this function for others to use (we shouldn't even 14 // be using this ourself). 15 // 16 // FIXME(thaJeztah): we should get rid of these hacks if possible. 17 func overrideUmask(newMask int) func() { 18 oldMask := unix.Umask(newMask) 19 return func() { 20 unix.Umask(oldMask) 21 } 22 }