• Kevin Burke's avatar
    os/user: retrieve Current username from /etc/passwd, not $USER · 3a18f0ec
    Kevin Burke authored
    Per golang/go#27524 there are situations where the username for the
    uid does not match the value in the $USER environment variable and it
    seems sensible to choose the value in /etc/passwd when they disagree.
    
    This may make the Current() call slightly more expensive, since we
    read /etc/passwd with cgo disabled instead of just checking the
    environment. However, we cache the result of Current() calls, so we
    only invoke this cost once in the lifetime of the process.
    
    Fixes #14626.
    Fixes #27524.
    Updates #24884.
    
    Change-Id: I0dcd224cf7f61dd5292f3fcc363aa2e9656a2cb1
    Reviewed-on: https://go-review.googlesource.com/134218Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    Run-TryBot: Ian Lance Taylor <iant@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    3a18f0ec
user_test.go 3.39 KB