diff_unix.go 634 B

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