From 22c70f268b30c703856143df848556515a824071 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 9 Nov 2016 20:35:46 +0000 Subject: [PATCH] syscall: use 32-bit setuid/setgid syscalls on linux/{386,arm} Fixes #17092 Change-Id: Ib14e4db13116ebbe4d72c414fb979d27a06d6174 Reviewed-on: https://go-review.googlesource.com/33011 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/syscall/exec_linux.go | 4 ++-- src/syscall/setuidgid_32_linux.go | 13 +++++++++++++ src/syscall/setuidgid_linux.go | 13 +++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 src/syscall/setuidgid_32_linux.go create mode 100644 src/syscall/setuidgid_linux.go diff --git a/src/syscall/exec_linux.go b/src/syscall/exec_linux.go index b0cad52f7bd..979b6a247a6 100644 --- a/src/syscall/exec_linux.go +++ b/src/syscall/exec_linux.go @@ -219,11 +219,11 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr goto childerror } } - _, _, err1 = RawSyscall(SYS_SETGID, uintptr(cred.Gid), 0, 0) + _, _, err1 = RawSyscall(sys_SETGID, uintptr(cred.Gid), 0, 0) if err1 != 0 { goto childerror } - _, _, err1 = RawSyscall(SYS_SETUID, uintptr(cred.Uid), 0, 0) + _, _, err1 = RawSyscall(sys_SETUID, uintptr(cred.Uid), 0, 0) if err1 != 0 { goto childerror } diff --git a/src/syscall/setuidgid_32_linux.go b/src/syscall/setuidgid_32_linux.go new file mode 100644 index 00000000000..182f5d26a90 --- /dev/null +++ b/src/syscall/setuidgid_32_linux.go @@ -0,0 +1,13 @@ +// Copyright 2016 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. + +// +build linux +// +build 386 arm + +package syscall + +const ( + sys_SETGID = SYS_SETGID32 + sys_SETUID = SYS_SETUID32 +) diff --git a/src/syscall/setuidgid_linux.go b/src/syscall/setuidgid_linux.go new file mode 100644 index 00000000000..bf40d2d8829 --- /dev/null +++ b/src/syscall/setuidgid_linux.go @@ -0,0 +1,13 @@ +// Copyright 2016 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. + +// +build linux +// +build !386,!arm + +package syscall + +const ( + sys_SETGID = SYS_SETGID + sys_SETUID = SYS_SETUID +)