1 //go:build linux && (386 || arm) 2 // +build linux 3 // +build 386 arm 4 5 package system 6 7 import ( 8 "golang.org/x/sys/unix" 9 ) 10 11 // Setuid sets the uid of the calling thread to the specified uid. 12 func Setuid(uid int) (err error) { 13 _, _, e1 := unix.RawSyscall(unix.SYS_SETUID32, uintptr(uid), 0, 0) 14 if e1 != 0 { 15 err = e1 16 } 17 return 18 } 19 20 // Setgid sets the gid of the calling thread to the specified gid. 21 func Setgid(gid int) (err error) { 22 _, _, e1 := unix.RawSyscall(unix.SYS_SETGID32, uintptr(gid), 0, 0) 23 if e1 != 0 { 24 err = e1 25 } 26 return 27 } 28