summaryrefslogtreecommitdiff
path: root/pkg/archive/diff_unix.go
blob: d7f806445e80e8b1c23f0facecbbf7d179a0afce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//go:build !windows
// +build !windows

package archive

import "golang.org/x/sys/unix"

// overrideUmask sets current process's file mode creation mask to newmask
// and returns a function to restore it.
//
// WARNING for readers stumbling upon this code. Changing umask in a multi-
// threaded environment isn't safe. Don't use this without understanding the
// risks, and don't export this function for others to use (we shouldn't even
// be using this ourself).
//
// FIXME(thaJeztah): we should get rid of these hacks if possible.
func overrideUmask(newMask int) func() {
	oldMask := unix.Umask(newMask)
	return func() {
		unix.Umask(oldMask)
	}
}