MCPcopy
hub / github.com/google/gvisor / Getgroups

Function Getgroups

pkg/sentry/syscalls/linux/sys_identity.go:142–164  ·  view source on GitHub ↗

Getgroups implements the Linux syscall getgroups.

(t *kernel.Task, sysno uintptr, args arch.SyscallArguments)

Source from the content-addressed store, hash-verified

140
141// Getgroups implements the Linux syscall getgroups.
142func Getgroups(t *kernel.Task, sysno uintptr, args arch.SyscallArguments) (uintptr, *kernel.SyscallControl, error) {
143 size := int(args[0].Int())
144 if size < 0 {
145 return 0, nil, linuxerr.EINVAL
146 }
147 kgids := t.Credentials().ExtraKGIDs
148 // "If size is zero, list is not modified, but the total number of
149 // supplementary group IDs for the process is returned." - getgroups(2)
150 if size == 0 {
151 return uintptr(len(kgids)), nil, nil
152 }
153 if size < len(kgids) {
154 return 0, nil, linuxerr.EINVAL
155 }
156 gids := make([]auth.GID, len(kgids))
157 for i, kgid := range kgids {
158 gids[i] = kgid.In(t.UserNamespace()).OrOverflow()
159 }
160 if _, err := auth.CopyGIDSliceOut(t, args[1].Pointer(), gids); err != nil {
161 return 0, nil, err
162 }
163 return uintptr(len(gids)), nil, nil
164}
165
166// Setgroups implements the Linux syscall setgroups.
167func Setgroups(t *kernel.Task, sysno uintptr, args arch.SyscallArguments) (uintptr, *kernel.SyscallControl, error) {

Callers

nothing calls this directly

Calls 6

CredentialsMethod · 0.65
UserNamespaceMethod · 0.65
IntMethod · 0.45
OrOverflowMethod · 0.45
InMethod · 0.45
PointerMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…