2014-10-21 03:20:08 +08:00
|
|
|
// +build linux,arm
|
2015-07-02 04:22:09 +08:00
|
|
|
|
2014-10-21 03:20:08 +08:00
|
|
|
package system
|
|
|
|
|
|
|
|
import (
|
|
|
|
"syscall"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Setuid sets the uid of the calling thread to the specified uid.
|
|
|
|
func Setuid(uid int) (err error) {
|
2014-11-17 21:14:19 +08:00
|
|
|
_, _, e1 := syscall.RawSyscall(syscall.SYS_SETUID32, 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) {
|
|
|
|
_, _, e1 := syscall.RawSyscall(syscall.SYS_SETGID32, uintptr(gid), 0, 0)
|
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|