go/src/os
Kir Kolyshkin 30faf968b1 os/user: implement go native GroupIds
Currently, GroupIds (a method that returns supplementary group IDs
for a user) is not implemented when cgo is not available, or osusergo
build tag is set, or the underlying OS lacks getgrouplist(3).

This adds a native Go implementation of GroupIds (which parses
/etc/group) for such cases, together with some tests.

This implementation is used:
 - when cgo is not available;
 - when osusergo build tag is set;
 - on AIX (which lacks getgrouplist(3));
 - on Illumos (which only recently added getgrouplist(3)).

This commit moves listgroups_unix.go to cgo_listgroups_unix.go, and adds
listgroups_unix.go which implements the feature.

NOTE the +build equivalent of go:build expression in listgroups_unix.go
is not provided as it is going to be bulky. Go 1.17 already prefers
go:build over +build, and no longer fail if a file contains go:build
without +build, so the absence of +build is not a problem even with Go
1.17, and this code is targeted for Go 1.18.

Updates #14709
Updates #30563

Change-Id: Icc95cda97ee3bcb03ef028b16eab7d3faba9ffab
Reviewed-on: https://go-review.googlesource.com/c/go/+/330753
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-21 23:11:47 +00:00
..
exec syscall: do not use handle lists on windows when NoInheritHandles is true 2021-09-17 00:31:49 +00:00
signal os/signal: test with a significantly longer fatal timeout 2021-06-20 11:17:27 +00:00
testdata testing/fstest,os: clarify racy behavior of TestFS 2021-01-08 16:34:00 +00:00
user os/user: implement go native GroupIds 2021-09-21 23:11:47 +00:00
dir.go os: add ReadFile, WriteFile, CreateTemp (was TempFile), MkdirTemp (was TempDir) from io/ioutil 2020-12-02 17:00:06 +00:00
dir_darwin.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
dir_plan9.go os: use keyed literals for PathError 2020-10-20 00:59:22 +00:00
dir_unix.go os: reuse readdir buffers on unix with a sync.Pool 2021-04-03 21:06:18 +00:00
dir_windows.go os: use keyed literals for PathError 2020-10-20 00:59:22 +00:00
dirent_aix.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
dirent_dragonfly.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
dirent_freebsd.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
dirent_js.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
dirent_linux.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
dirent_netbsd.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
dirent_openbsd.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
dirent_solaris.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
endian_big.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
endian_little.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
env.go
env_test.go
env_unix_test.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
error.go os: update some docs to reference fs.ErrFoo instead of os.ErrFoo 2021-05-03 22:01:04 +00:00
error_errno.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
error_plan9.go
error_posix.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
error_test.go os: restore testErrNotExist's working directory on os.Chdir success 2021-04-12 22:19:11 +00:00
error_unix_test.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
error_windows_test.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
example_test.go os: change example to avoid deprecated function 2021-06-30 16:44:19 +00:00
exec.go os: document that StartProcess puts files into blocking mode 2021-05-21 20:38:43 +00:00
exec_plan9.go all: add internal/itoa package 2021-03-14 17:56:50 +00:00
exec_posix.go all: add internal/itoa package 2021-03-14 17:56:50 +00:00
exec_unix.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
exec_unix_test.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
exec_windows.go os: avoid finalizer race in windows process object 2021-06-04 17:21:49 +00:00
executable.go
executable_darwin.go
executable_dragonfly.go os: gofmt 2020-11-12 10:22:50 +00:00
executable_freebsd.go os: gofmt 2020-11-12 10:22:50 +00:00
executable_path.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
executable_plan9.go all: add internal/itoa package 2021-03-14 17:56:50 +00:00
executable_procfs.go os: depend on Readlink only when necessary 2021-04-22 21:03:32 +00:00
executable_solaris.go
executable_sysctl.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
executable_test.go os: skip TestExecutableDeleted on plan9 2021-05-04 18:47:19 +00:00
executable_windows.go
export_linux_test.go os, internal/poll, internal/syscall/unix: use copy_file_range on Linux 2020-04-28 00:59:36 +00:00
export_test.go os: add ReadFile, WriteFile, CreateTemp (was TempFile), MkdirTemp (was TempDir) from io/ioutil 2020-12-02 17:00:06 +00:00
export_unix_test.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
export_windows_test.go runtime: support long paths without fixup on Windows 10 >= 1607 2021-03-23 03:49:17 +00:00
fifo_test.go os: enable TestFifoEOF on openbsd 2021-06-24 00:14:41 +00:00
file.go os: implement fs.StatFS for os.DirFS 2021-04-06 04:48:09 +00:00
file_plan9.go os: document that Windows Symlink to missing target creates file symlink 2021-05-02 18:22:19 +00:00
file_posix.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
file_unix.go os: document that Windows Symlink to missing target creates file symlink 2021-05-02 18:22:19 +00:00
file_windows.go os: document that Windows Symlink to missing target creates file symlink 2021-05-02 18:22:19 +00:00
getwd.go os: remove ENOTSUP special case in Getwd on darwin 2020-09-28 06:28:02 +00:00
os_test.go os: replace os.MkdirTemp with T.TempDir 2021-04-09 09:01:07 +00:00
os_unix_test.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
os_windows_test.go os: replace os.MkdirTemp with T.TempDir 2021-04-09 09:01:07 +00:00
path.go os: use keyed literals for PathError 2020-10-20 00:59:22 +00:00
path_plan9.go
path_test.go os: replace os.MkdirTemp with T.TempDir 2021-04-09 09:01:07 +00:00
path_unix.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
path_windows.go runtime: support long paths without fixup on Windows 10 >= 1607 2021-03-23 03:49:17 +00:00
path_windows_test.go os: replace os.MkdirTemp with T.TempDir 2021-04-09 09:01:07 +00:00
pipe2_bsd.go syscall, os: use pipe2 syscall on DragonflyBSD instead of pipe 2021-02-25 09:20:03 +00:00
pipe2_illumos.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
pipe_bsd.go syscall, os: use pipe2 syscall on DragonflyBSD instead of pipe 2021-02-25 09:20:03 +00:00
pipe_linux.go os, syscall: remove fallback to pipe syscall on Linux 2021-09-02 09:24:44 +00:00
pipe_test.go os: deflake TestFdReadRace 2021-05-26 23:33:38 +00:00
proc.go cmd/go, testing, os: fail test that calls os.Exit(0) 2020-08-27 23:19:15 +00:00
rawconn.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
rawconn_test.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
read_test.go os: add ReadFile, WriteFile, CreateTemp (was TempFile), MkdirTemp (was TempDir) from io/ioutil 2020-12-02 17:00:06 +00:00
readfrom_linux.go os: fix regression with handling of nil *File 2020-07-08 18:29:38 +00:00
readfrom_linux_test.go docs: fix spelling 2021-02-24 04:11:43 +00:00
readfrom_stub.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
removeall_at.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
removeall_noat.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
removeall_test.go os: replace os.MkdirTemp with T.TempDir 2021-04-09 09:01:07 +00:00
stat.go
stat_aix.go
stat_darwin.go
stat_dragonfly.go
stat_freebsd.go
stat_js.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
stat_linux.go
stat_netbsd.go
stat_openbsd.go
stat_plan9.go os: use keyed literals for PathError 2020-10-20 00:59:22 +00:00
stat_solaris.go
stat_test.go os: replace os.MkdirTemp with T.TempDir 2021-04-09 09:01:07 +00:00
stat_unix.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
stat_windows.go os: use keyed literals for PathError 2020-10-20 00:59:22 +00:00
sticky_bsd.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
sticky_notbsd.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
str.go all: add internal/itoa package 2021-03-14 17:56:50 +00:00
sys.go
sys_aix.go
sys_bsd.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
sys_js.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
sys_linux.go
sys_plan9.go
sys_solaris.go
sys_unix.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
sys_windows.go
tempfile.go all: add internal/itoa package 2021-03-14 17:56:50 +00:00
tempfile_test.go os: add ReadFile, WriteFile, CreateTemp (was TempFile), MkdirTemp (was TempDir) from io/ioutil 2020-12-02 17:00:06 +00:00
timeout_test.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
types.go io/fs: move FileInfo, FileMode, PathError, ErrInvalid, ... from os to io/fs 2020-10-20 02:32:41 +00:00
types_plan9.go
types_unix.go all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
types_windows.go os: use keyed literals for PathError 2020-10-20 00:59:22 +00:00
wait_unimp.go os, syscall: use wait6 to avoid wait/kill race on netbsd 2021-05-04 12:44:42 +00:00
wait_wait6.go os, syscall: use wait6 to avoid wait/kill race on netbsd 2021-05-04 12:44:42 +00:00
wait_waitid.go all: simplify the spelling of Linux 2021-04-13 13:56:21 +00:00