feat: Add pidns flag
This commit is contained in:
parent
a1121f8260
commit
66aeae6166
1 changed files with 5 additions and 1 deletions
6
main.go
6
main.go
|
@ -12,6 +12,7 @@ import (
|
|||
var rootPath = flag.String("root", "", "path to root directory")
|
||||
var initCmd = flag.String("init", "/sbin/init", "init command")
|
||||
var workdir = flag.String("workdir", "/", "work directory")
|
||||
var pidns = flag.Bool("pidns", false, "create pid namespace")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
@ -26,7 +27,7 @@ func main() {
|
|||
cmd.Dir = *workdir
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
Chroot: *rootPath,
|
||||
Cloneflags: syscall.CLONE_NEWUSER|syscall.CLONE_NEWPID,
|
||||
Cloneflags: syscall.CLONE_NEWUSER,
|
||||
UidMappings: []syscall.SysProcIDMap{
|
||||
{ContainerID: 0, HostID: os.Getuid(), Size: 1},
|
||||
},
|
||||
|
@ -34,6 +35,9 @@ func main() {
|
|||
{ContainerID: 0, HostID: os.Getgid(), Size: 1},
|
||||
},
|
||||
}
|
||||
if *pidns {
|
||||
cmd.SysProcAttr.Cloneflags |= syscall.CLONE_NEWPID
|
||||
}
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
|
|
Loading…
Reference in a new issue