Benoit Sigoure
54535356f1
x/sys/unix: Add support for the setns system call.
...
This system call is used to reassociate the current thread with a Linux
namespace (e.g. a network namespace or a mount namespace). This system
call is key to interacting with the primitives enabling Linux containers.
The users of this system call will most likely want to wrap their calls
with a pair of LockOSThread / UnlockOSThread calls. Here is an example
that is a reasonably close approximation of the `ns_exec' program given
as an example in `man 2 setns':
package main
import (
"log"
"os"
"os/exec"
"runtime"
"golang.org/x/sys/unix"
)
func main() {
if len(os.Args) < 3 {
log.Fatalf("%s /proc/PID/ns/FILE cmd args...", os.Args[0])
}
fd, err := unix.Open(os.Args[1], unix.O_RDONLY, 0)
if err != nil {
log.Fatalf("open: %s", err)
}
runtime.LockOSThread()
defer runtime.UnlockOSThread()
if err = unix.Setns(fd, 0); err != nil {
log.Fatalf("setns: %s", err)
}
cmd := exec.Command(os.Args[2], os.Args[3:]...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err = cmd.Run()
if err != nil {
log.Fatalf("exec: %s", err)
}
}
Fixes golang/go#5968 .
Change-Id: I78dc54667cfaef4f9e99a08d48f6e423686f1b22
Reviewed-on: https://go-review.googlesource.com/20054
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org >
2016-02-29 17:26:46 +00:00
..
2015-09-02 01:15:37 +00:00
2015-05-07 23:38:20 +00:00
2015-05-07 23:38:20 +00:00
2015-05-18 19:16:22 +00:00
2015-05-18 19:16:10 +00:00
2015-05-07 23:38:20 +00:00
2015-05-07 23:38:20 +00:00
2015-05-07 23:38:20 +00:00
2015-05-07 23:38:20 +00:00
2015-05-07 23:38:20 +00:00
2015-05-07 23:38:20 +00:00
2015-05-07 23:38:20 +00:00
2015-05-18 19:15:57 +00:00
2015-05-07 23:38:20 +00:00
2016-02-28 04:28:12 +00:00
2015-05-14 00:30:18 +00:00
2015-05-07 23:38:20 +00:00
2015-05-07 23:38:20 +00:00
2015-05-07 23:38:20 +00:00
2015-05-07 23:38:20 +00:00
2015-05-07 23:38:20 +00:00
2015-08-19 10:26:52 +00:00
2015-05-07 23:38:20 +00:00
2015-03-20 06:12:11 +00:00
2015-05-12 03:31:30 +00:00
2014-08-13 09:00:28 -07:00
2014-10-01 12:10:37 -07:00
2015-05-14 06:54:30 +00:00
2014-08-11 15:58:26 -07:00
2014-08-12 22:59:00 -07:00
2015-05-12 03:04:57 +00:00
2015-05-07 23:38:20 +00:00
2015-05-12 03:04:57 +00:00
2015-09-02 01:15:37 +00:00
2015-11-23 20:52:33 +00:00
2015-09-17 18:12:33 +00:00
2015-05-15 01:18:51 +00:00
2015-05-15 01:18:51 +00:00
2015-05-15 01:18:51 +00:00
2015-05-15 01:18:51 +00:00
2015-05-15 01:18:51 +00:00
2015-05-15 01:18:51 +00:00
2015-05-15 01:18:51 +00:00
2015-05-15 01:18:51 +00:00
2015-08-21 20:53:45 +00:00
2014-08-13 20:54:29 -07:00
2014-08-13 20:54:29 -07:00
2014-08-11 15:58:26 -07:00
2015-10-09 04:16:36 +00:00
2015-05-13 20:12:53 +00:00
2016-02-04 22:58:17 +00:00
2015-10-29 18:30:43 +00:00
2015-09-01 16:49:45 +00:00
2015-09-02 01:16:36 +00:00
2015-09-01 13:17:12 +00:00
2015-05-18 19:16:10 +00:00
2015-03-26 17:59:35 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-03-26 17:59:35 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-10-29 18:30:43 +00:00
2015-03-27 16:47:22 +00:00
2016-02-28 22:21:53 +00:00
2016-02-28 22:21:53 +00:00
2016-02-28 22:21:53 +00:00
2016-02-28 22:21:53 +00:00
2016-02-28 22:21:53 +00:00
2016-02-28 22:21:53 +00:00
2016-02-28 22:21:53 +00:00
2016-02-29 17:26:46 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-03-26 17:59:35 +00:00
2014-08-11 15:58:26 -07:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-03-26 17:59:35 +00:00
2015-09-10 21:42:51 +00:00
2016-01-27 15:07:42 +00:00
2015-05-13 20:12:53 +00:00
2015-05-07 23:38:20 +00:00
2015-03-27 16:15:35 +00:00
2014-12-09 22:46:33 +00:00
2015-09-02 01:16:36 +00:00
2014-08-11 15:58:26 -07:00
2015-03-27 16:47:22 +00:00
2016-02-28 04:28:12 +00:00
2014-08-11 15:58:26 -07:00
2014-08-11 15:58:26 -07:00
2015-09-24 17:12:55 +00:00
2015-09-01 16:49:45 +00:00
2015-08-31 01:45:38 +00:00
2015-09-01 13:17:12 +00:00
2015-05-18 19:16:10 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-09-25 17:03:07 +00:00
2015-09-25 17:03:07 +00:00
2015-05-18 19:15:57 +00:00
2015-11-23 20:52:33 +00:00
2015-11-23 20:52:33 +00:00
2015-11-23 20:52:33 +00:00
2015-11-23 20:52:33 +00:00
2016-02-28 04:28:12 +00:00
2016-02-28 04:28:12 +00:00
2015-11-23 20:52:33 +00:00
2015-11-23 20:52:33 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-09-24 17:12:55 +00:00
2015-05-18 19:15:57 +00:00
2015-09-02 01:16:36 +00:00
2015-05-18 19:16:22 +00:00
2015-05-18 19:16:10 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2016-02-29 17:26:46 +00:00
2016-02-29 17:26:46 +00:00
2016-02-29 17:26:46 +00:00
2016-02-29 17:26:46 +00:00
2016-02-29 17:26:46 +00:00
2016-02-29 17:26:46 +00:00
2016-02-29 17:26:46 +00:00
2016-02-29 17:26:46 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2016-01-27 15:07:42 +00:00
2014-08-11 15:58:26 -07:00
2015-09-01 16:49:45 +00:00
2015-08-31 05:03:18 +00:00
2015-09-02 01:15:37 +00:00
2015-05-18 19:16:10 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2016-02-28 04:28:12 +00:00
2016-02-28 04:28:12 +00:00
2015-05-17 01:16:40 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-09-01 16:49:45 +00:00
2015-09-02 01:16:36 +00:00
2015-09-01 13:17:12 +00:00
2015-05-18 19:16:10 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-09-25 17:03:07 +00:00
2015-09-25 17:03:07 +00:00
2015-05-18 19:15:57 +00:00
2015-11-24 18:47:04 +00:00
2015-11-24 18:47:04 +00:00
2015-11-24 18:47:04 +00:00
2015-11-24 18:47:04 +00:00
2016-02-28 04:28:12 +00:00
2016-02-28 04:28:12 +00:00
2015-11-24 18:47:04 +00:00
2015-11-24 18:47:04 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-05-18 19:15:57 +00:00
2015-09-24 17:12:55 +00:00