summaryrefslogtreecommitdiff
path: root/src/os/user
Commit message (Collapse)AuthorAgeFilesLines
* os/user: fake Current on AndroidElias Naur2017-03-082-5/+14
| | | | | | | | | | | | | | | On Android devices where the stub fallback for Current fails to extract a User from the environment, return a dummy fallback instead of failing. While we're here, use / instead of /home/nacl for the NaCL fallback. Hopefully fixes the Android builder. Change-Id: Ia29304fbc224ee5f9c0f4e706d1756f765a7eae5 Reviewed-on: https://go-review.googlesource.com/37960 Run-TryBot: Elias Naur <elias.naur@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* os/user: use the stubs fallback for AndroidElias Naur2017-03-072-14/+4
| | | | | | | | | | | Using the stubs, user.Current will no longer fail on Android, fixing the os/exec.TestCredentialNoSetGroups test. Change-Id: I8b9842aa6704c0cde383c549a614bab0a0ed7695 Reviewed-on: https://go-review.googlesource.com/37765 Run-TryBot: Elias Naur <elias.naur@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* os/user: add non-cgo versions of Lookup, LookupIdKevin Burke2017-03-044-41/+292
| | | | | | | | | | | | | | | | If you cross compile for a Unix target and call user.Lookup("root") or user.LookupId("0"), we'll try to read the answer out of /etc/passwd instead of returning an "unimplemented" error. The equivalent cgo function calls getpwuid_r in glibc, which may reach out to the NSS database or allow callers to register extensions. The pure Go implementation only reads from /etc/passwd. Change-Id: I56a302d634b15ba5097f9f0d6a758c68e486ba6d Reviewed-on: https://go-review.googlesource.com/37664 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* os/user: add Go implementation of LookupGroup, LookupGroupIdKevin Burke2017-02-273-8/+216
| | | | | | | | | | | | | | If cgo is not available, parse /etc/group in Go to find the name/gid we need. This does not consult the Network Information System (NIS), /etc/nsswitch.conf or any other libc extensions to /etc/group. Fixes #18102. Change-Id: I6ae4fe0e2c899396c45cdf243d5483113932657c Reviewed-on: https://go-review.googlesource.com/33713 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* os/user: rename group cgo fileKevin Burke2017-02-271-0/+0
| | | | | | | | | | | | | | In another CL, I'll add a pure Go implementation of lookupGroup and lookupGroupId in lookup_unix.go, but attempting that in one CL makes the diff too difficult to read. Updates #18102. Change-Id: If8e26cee5efd30385763430f34304c70165aef32 Reviewed-on: https://go-review.googlesource.com/37497 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* os/user: cache the result of user.CurrentSameer Ajmani2017-02-062-1/+27
| | | | | | | | | | | | | | | | | | | This has a notable impact on systems with very large passwd files. Before: BenchmarkCurrent-12 30000 42546 ns/op After: BenchmarkCurrent-12 20000000 77.5 ns/op Saved in perf dashboard: https://perf.golang.org/search?q=upload:20170206.1 Fixes #11625 Change-Id: Iebc9bf122cc64a4cab24ac06843c7b2bc450ded9 Reviewed-on: https://go-review.googlesource.com/36391 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* os/user: document the difference between Username and NameKevin Burke2017-01-071-14/+22
| | | | | | | | Fixes #18261. Change-Id: I4bd7363aac4e62461f61fd95b3c7a18063412182 Reviewed-on: https://go-review.googlesource.com/34241 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* os/user: don't create C function mygetgrouplistIan Lance Taylor2016-05-103-8/+21
| | | | | | | | | | | | Instead of exporting the C function mygetgrouplist as a global symbol to conflict with other symbols of the same name, use trivial Go code and a static C function. Change-Id: I98dd667814d0a0ed8f7b1d4cfc6483d5a6965b26 Reviewed-on: https://go-review.googlesource.com/23008 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* os/user: wrap getgrnam_r to fix type issuesRoss Light2016-04-061-1/+6
| | | | | | | | | | | | | Even with -D_POSIX_PTHREAD_SEMANTICS, Solaris seems to not define getgrnam_r in a POSIX compatible way. Fixes #14967 Change-Id: I78cb7e5b30b2d8b860e336060a0a06f4720c0475 Reviewed-on: https://go-review.googlesource.com/21385 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* os/user: allow LookupGroupId to fail during testRuss Cox2016-03-151-1/+5
| | | | | | | | | | | | On my Mac I am in group 5000 which apparently has no name (I suspect because it is an LDAP group and I cannot reach the LDAP server). Do not make the test fail in that case. Fixes #14806 Change-Id: I56b11a8e86b048abfb00812eaad37802fd2adcc5 Reviewed-on: https://go-review.googlesource.com/20710 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* os/user: fix formatting of error group lookup messageBrad Fitzpatrick2016-03-141-1/+1
| | | | | | | | | | | | It was failing like "unknown groupid ᎈ|" instead of "unknown groupid 5000" due to the conversion from int to string. Updates #14806 Change-Id: I83e4b478ff628ad4053573a9f32b3fadce22e847 Reviewed-on: https://go-review.googlesource.com/20642 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org>
* os/user: make OS-specific getgrouplist callsRoss Light2016-03-086-37/+110
| | | | | | | | | | | | | | | | getgrouplist is non-standard and has slightly different semantics on each platform. Darwin defines the function in terms of ints instead of gid_ts. Solaris only recently supported the call, so stubbing out for now. Fixes #14696 Fixes #14709 Change-Id: I5a44538d41594909efb6f3f9610c55d638c36757 Reviewed-on: https://go-review.googlesource.com/20348 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* os/user: skip Current test on androidBrad Fitzpatrick2016-03-082-2/+5
| | | | | | | | | | | | | Also, add more failure output to debug why linux/mips64le and linux/ppc64 are failing. They should be working. I suspect their builder test envs are missing something. Change-Id: I97273fe72c4e3009db400394636d0da1ef147485 Reviewed-on: https://go-review.googlesource.com/20358 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* os/user: make Current work without cgoBrad Fitzpatrick2016-03-072-4/+48
| | | | | | | | | Fixes #14626 Change-Id: I91c40407dc35355e5c5046f24111a126f99260d9 Reviewed-on: https://go-review.googlesource.com/20192 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Minux Ma <minux@golang.org>
* os/user: add LookupGroup, LookupGroupId, and User.GroupIds functionsRoss Light2016-03-078-73/+437
| | | | | | | | | | | | | | | | | As part of local testing with a large group member list, I discovered that the lookup functions don't resize their buffer if they receive ERANGE. I fixed this as a side-effect of this CL. Thanks to @andrenth for the original CL. Fixes #2617 Change-Id: Ie6aae2fe0a89eae5cce85786869a8acaa665ffe9 Reviewed-on: https://go-review.googlesource.com/19235 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* all: single space after period.Brad Fitzpatrick2016-03-021-1/+1
| | | | | | | | | | | | | | | | | | | | The tree's pretty inconsistent about single space vs double space after a period in documentation. Make it consistently a single space, per earlier decisions. This means contributors won't be confused by misleading precedence. This CL doesn't use go/doc to parse. It only addresses // comments. It was generated with: $ perl -i -npe 's,^(\s*// .+[a-z]\.) +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.) +([A-Z])') $ go test go/doc -update Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7 Reviewed-on: https://go-review.googlesource.com/20022 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Dave Day <djd@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* all: fix typos and spellingMartin Möhrmann2016-02-241-1/+1
| | | | | | | | Change-Id: Icd06d99c42b8299fd931c7da821e1f418684d913 Reviewed-on: https://go-review.googlesource.com/19829 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* os/user: don't depend on _SC_GETPW_R_SIZE_MAX on LinuxDominik Honnef2015-08-211-11/+8
| | | | | | | | | | | | | Even Linux systems may not have _SC_GETPW_R_SIZE_MAX if using a different libc than glibc (e.g. musl). Instead of having special-cases for the BSDs, handle -1 correctly by always using a default buffer size. Fixes #11319. Change-Id: I8b1b260eb9830e6dbe7667f3f33d115ae4de4ce8 Reviewed-on: https://go-review.googlesource.com/13772 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
* os/user: small fixes for SolarisAram Hăvărneanu2015-05-061-2/+12
| | | | | | Change-Id: I56149ef6607fb4d9baff9047cb3a47d71cad6fa6 Reviewed-on: https://go-review.googlesource.com/8261 Reviewed-by: Minux Ma <minux@golang.org>
* build: move package sources from src/pkg to srcRuss Cox2014-09-087-0/+489
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.