syscall_linux_64.go 557 B

1234567891011121314151617181920212223242526
  1. // +build linux
  2. // +build arm64 amd64 mips mipsle mips64 mips64le ppc ppc64 ppc64le s390x
  3. package system
  4. import (
  5. "golang.org/x/sys/unix"
  6. )
  7. // Setuid sets the uid of the calling thread to the specified uid.
  8. func Setuid(uid int) (err error) {
  9. _, _, e1 := unix.RawSyscall(unix.SYS_SETUID, uintptr(uid), 0, 0)
  10. if e1 != 0 {
  11. err = e1
  12. }
  13. return
  14. }
  15. // Setgid sets the gid of the calling thread to the specified gid.
  16. func Setgid(gid int) (err error) {
  17. _, _, e1 := unix.RawSyscall(unix.SYS_SETGID, uintptr(gid), 0, 0)
  18. if e1 != 0 {
  19. err = e1
  20. }
  21. return
  22. }