2015-04-11 02:50:45 +08:00
|
|
|
// +build linux,arm64 linux,amd64 linux,ppc linux,ppc64 linux,ppc64le linux,s390x
|
2014-11-06 00:56:47 +08:00
|
|
|
|
2014-10-21 03:20:08 +08:00
|
|
|
package system
|
|
|
|
|
|
|
|
import (
|
2017-05-10 05:38:27 +08:00
|
|
|
"golang.org/x/sys/unix"
|
2014-10-21 03:20:08 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// Setuid sets the uid of the calling thread to the specified uid.
|
|
|
|
func Setuid(uid int) (err error) {
|
2017-05-10 05:38:27 +08:00
|
|
|
_, _, e1 := unix.RawSyscall(unix.SYS_SETUID, uintptr(uid), 0, 0)
|
2014-10-21 03:20:08 +08:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setgid sets the gid of the calling thread to the specified gid.
|
|
|
|
func Setgid(gid int) (err error) {
|
2017-05-10 05:38:27 +08:00
|
|
|
_, _, e1 := unix.RawSyscall(unix.SYS_SETGID, uintptr(gid), 0, 0)
|
2014-10-21 03:20:08 +08:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|