summaryrefslogtreecommitdiff
path: root/src/lib/os/user.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/os/user.go')
-rw-r--r--src/lib/os/user.go64
1 files changed, 0 insertions, 64 deletions
diff --git a/src/lib/os/user.go b/src/lib/os/user.go
deleted file mode 100644
index 194aa50e4..000000000
--- a/src/lib/os/user.go
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// User ids etc.
-
-package os
-
-import (
- "syscall";
- "os";
- "unsafe";
-)
-
-// Getuid returns the numeric user id of the caller.
-func Getuid() int {
- u, r2, e := syscall.Syscall(syscall.SYS_GETUID, 0, 0, 0);
- return int(u);
-}
-
-// Geteuid returns the numeric effective user id of the caller.
-func Geteuid() int {
- u, r2, e := syscall.Syscall(syscall.SYS_GETEUID, 0, 0, 0);
- return int(u);
-}
-
-// Getgid returns the numeric group id of the caller.
-func Getgid() int {
- g, r2, e := syscall.Syscall(syscall.SYS_GETGID, 0, 0, 0);
- return int(g);
-}
-
-// Getegid returns the numeric effective group id of the caller.
-func Getegid() int {
- g, r2, e := syscall.Syscall(syscall.SYS_GETEGID, 0, 0, 0);
- return int(g);
-}
-
-// Getgroups returns a list of the numeric ids of groups that the caller belongs to.
-func Getgroups() ([]int, os.Error) {
- // first call asks how many there are.
- r1, r2, err := syscall.Syscall(syscall.SYS_GETGROUPS, 0, 0, 0);
- if err != 0 {
- return nil, ErrnoToError(err);
- }
-
- // Sanity check group count.
- // On Linux, max is 1<<16; on BSD, OS X, max is 16.
- if r1 < 0 || r1 > 1<<20 {
- return nil, EINVAL;
- }
- a := make([]int, r1);
- if r1 > 0 {
- tmp := make([]uint32, r1);
- r1, r2, err = syscall.Syscall(syscall.SYS_GETGROUPS, r1, int64(uintptr(unsafe.Pointer(&tmp[0]))), 0);
- if err != 0 {
- return nil, ErrnoToError(err);
- }
- for i := 0; i < len(a); i++ {
- a[i] = int(tmp[i]);
- }
- }
- return a[0:r1], nil;
-}