]> Cypherpunks repositories - gostls13.git/commit
os/user: retrieve Current username from /etc/passwd, not $USER
authorKevin Burke <kev@inburke.com>
Sat, 8 Sep 2018 19:35:03 +0000 (12:35 -0700)
committerKevin Burke <kev@inburke.com>
Sun, 9 Sep 2018 19:24:00 +0000 (19:24 +0000)
commit3a18f0ecb5748488501c565e995ec12a29e66966
tree61ac89357deffadc2cf3d4ef626f0c7211ad6ffa
parent1705962cf976a001bb9929146e5690a957ed630e
os/user: retrieve Current username from /etc/passwd, not $USER

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/134218
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/os/user/lookup_stubs.go
src/os/user/user_test.go