diff options
author | Sebastiaan van Stijn <thaJeztah@users.noreply.github.com> | 2021-02-12 11:58:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-12 11:58:29 +0100 |
commit | 69f9c8c90662290f3e3abc01a3be51b95b80367b (patch) | |
tree | 93c611db7760cf4d3b2ec7db838f53220b0a4c32 | |
parent | 420b1d36250f9cfdc561f086f25a213ecb669b6f (diff) | |
parent | df6c53c924c26cded65c76d31947fd33295076e2 (diff) | |
download | docker-19.03.tar.gz |
Merge pull request #41948 from AkihiroSuda/cherrypick-41892-190319.03
[19.03 backport] pkg/archive: allow mknodding FIFO inside userns
-rw-r--r-- | pkg/archive/archive_unix.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/pkg/archive/archive_unix.go b/pkg/archive/archive_unix.go index d626336032..85f350bb76 100644 --- a/pkg/archive/archive_unix.go +++ b/pkg/archive/archive_unix.go @@ -81,11 +81,6 @@ func getFileUIDGID(stat interface{}) (idtools.Identity, error) { // handleTarTypeBlockCharFifo is an OS-specific helper function used by // createTarFile to handle the following types of header: Block; Char; Fifo func handleTarTypeBlockCharFifo(hdr *tar.Header, path string) error { - if rsystem.RunningInUserNS() { - // cannot create a device if running in user namespace - return nil - } - mode := uint32(hdr.Mode & 07777) switch hdr.Typeflag { case tar.TypeBlock: @@ -96,7 +91,12 @@ func handleTarTypeBlockCharFifo(hdr *tar.Header, path string) error { mode |= unix.S_IFIFO } - return system.Mknod(path, mode, int(system.Mkdev(hdr.Devmajor, hdr.Devminor))) + err := system.Mknod(path, mode, int(system.Mkdev(hdr.Devmajor, hdr.Devminor))) + if errors.Is(err, syscall.EPERM) && rsystem.RunningInUserNS() { + // In most cases, cannot create a device if running in user namespace + err = nil + } + return err } func handleLChmod(hdr *tar.Header, path string, hdrInfo os.FileInfo) error { |