-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for Setuid/Setgid calls that has been removed from
go HEAD and won't be available in go 1.4. Docker-DCO-1.1-Signed-off-by: Mrunal Patel <[email protected]> (github: mrunalp)
- Loading branch information
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// +build linux,386 | ||
package system | ||
|
||
import ( | ||
"syscall" | ||
) | ||
|
||
// Setuid sets the uid of the calling thread to the specified uid. | ||
func Setuid(uid int) (err error) { | ||
_, _, e1 := syscall.RawSyscall(syscall.SYS_SETUID, uintptr(uid), 0, 0) | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// +build linux,amd64 | ||
package system | ||
|
||
import ( | ||
"syscall" | ||
) | ||
|
||
// Setuid sets the uid of the calling thread to the specified uid. | ||
func Setuid(uid int) (err error) { | ||
_, _, e1 := syscall.RawSyscall(syscall.SYS_SETUID, uintptr(uid), 0, 0) | ||
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_SETGID, uintptr(gid), 0, 0) | ||
if e1 != 0 { | ||
err = e1 | ||
} | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// +build linux,arm | ||
package system | ||
|
||
import ( | ||
"syscall" | ||
) | ||
|
||
// Setuid sets the uid of the calling thread to the specified uid. | ||
func Setuid(uid int) (err error) { | ||
_, _, e1 := syscall.RawSyscall(syscall.SYS_SETUID, uintptr(uid), 0, 0) | ||
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 | ||
} |