Permalink
Browse files

use setgroups in syscall

  • Loading branch information...
1 parent 4091de9 commit e4ef8c08748ce48e741ee638633fd07828c9824e @bradfitz committed Jan 2, 2012
Showing with 1 addition and 19 deletions.
  1. +1 −1 exec.go
  2. +0 −18 groups.go
View
2 exec.go
@@ -102,7 +102,7 @@ func MaybeBecomeChildProcess() {
}
}
if len(lr.Gids) != 0 {
- if err := SetGroups(lr.Gids); err != nil {
+ if err := syscall.Setgroups(lr.Gids); err != nil {
log.Printf("setgroups: %v", err)
}
}
View
18 groups.go
@@ -25,26 +25,8 @@ import (
"os"
"strconv"
"strings"
- "unsafe"
)
-/*
-#include <grp.h>
-*/
-import "C"
-
-func SetGroups(gids []int) error {
- if len(gids) == 0 {
- return nil
- }
- list := make([]C.gid_t, len(gids))
- for i, gid := range gids {
- list[i] = C.gid_t(gid)
- }
- _, err := C.setgroups(C.size_t(len(list)), (*_Ctype___gid_t)(unsafe.Pointer(&list[0])))
- return err
-}
-
func LookupGroupId(group string) (gid int, err error) {
f, err := os.Open("/etc/group")
if err != nil {

0 comments on commit e4ef8c0

Please sign in to comment.