github.com/docker/docker@v299999999.0.0-20200612211812-aaf470eca7b5+incompatible/patches/0001-archive-tar-do-not-populate-user-group-names.patch (about)

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