1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/patches/0001-archive-tar-do-not-populate-user-group-names.patch
Brian Goff 841c1f3388 Remove blurb about fixed in go1.11 in patch file
This blurb exists because we reused the same commit from an old patch,
and thus got the commit message with it. However the message is
confusing in this context.
It was suggested in review that we should remove the confusing message.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2020-04-24 11:23:14 -07:00

75 lines
2.3 KiB
Diff

From bc0de86b495ae014b209431ed7cb90fc3d5e4d1f Mon Sep 17 00:00:00 2001
From: Kir Kolyshkin <kolyshkin@gmail.com>
Date: Mon, 9 Apr 2018 15:58:40 -0700
Subject: [PATCH] archive/tar: do not populate user/group names
This reverts part of commit 29a18899379c ("archive/tar: populate
uname/gname/devmajor/devminor in FileInfoHeader"). The reason is
using os/user functions to resolved uids/gids to names breaks
the static build for Linux/glibc case (the resulting binary panics
on NULL pointer dereference).
For much more details, see https://github.com/golang/go/issues/23265
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
---
src/archive/tar/stat_unix.go | 26 +++-----------------------
1 file changed, 3 insertions(+), 23 deletions(-)
diff --git a/src/archive/tar/stat_unix.go b/src/archive/tar/stat_unix.go
index 868105f338..9640ed4bab 100644
--- a/src/archive/tar/stat_unix.go
+++ b/src/archive/tar/stat_unix.go
@@ -8,10 +8,7 @@ package tar
import (
"os"
- "os/user"
"runtime"
- "strconv"
- "sync"
"syscall"
)
@@ -19,10 +16,6 @@ func init() {
sysStat = statUnix
}
-// userMap and groupMap caches UID and GID lookups for performance reasons.
-// The downside is that renaming uname or gname by the OS never takes effect.
-var userMap, groupMap sync.Map // map[int]string
-
func statUnix(fi os.FileInfo, h *Header) error {
sys, ok := fi.Sys().(*syscall.Stat_t)
if !ok {
@@ -31,22 +24,9 @@ func statUnix(fi os.FileInfo, h *Header) error {
h.Uid = int(sys.Uid)
h.Gid = int(sys.Gid)
- // Best effort at populating Uname and Gname.
- // The os/user functions may fail for any number of reasons
- // (not implemented on that platform, cgo not enabled, etc).
- if u, ok := userMap.Load(h.Uid); ok {
- h.Uname = u.(string)
- } else if u, err := user.LookupId(strconv.Itoa(h.Uid)); err == nil {
- h.Uname = u.Username
- userMap.Store(h.Uid, h.Uname)
- }
- if g, ok := groupMap.Load(h.Gid); ok {
- h.Gname = g.(string)
- } else if g, err := user.LookupGroupId(strconv.Itoa(h.Gid)); err == nil {
- h.Gname = g.Name
- groupMap.Store(h.Gid, h.Gname)
- }
-
+ // TODO(bradfitz): populate username & group. os/user
+ // doesn't cache LookupId lookups, and lacks group
+ // lookup functions.
h.AccessTime = statAtime(sys)
h.ChangeTime = statCtime(sys)
base-commit: 4af1337d1e9eb9e7b766c9deb787c78413bb25c4
--
2.24.1