github.com/moby/docker@v26.1.3+incompatible/pkg/archive/diff_unix.go (about)

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