mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #5392 from rjnagal/libcontainer-fixes
Minor libcontainer fixes
This commit is contained in:
commit
fbc7a069f2
3 changed files with 62 additions and 3 deletions
59
pkg/libcontainer/container_test.go
Normal file
59
pkg/libcontainer/container_test.go
Normal file
|
@ -0,0 +1,59 @@
|
|||
package libcontainer
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestContainerJsonFormat(t *testing.T) {
|
||||
f, err := os.Open("container.json")
|
||||
if err != nil {
|
||||
t.Fatal("Unable to open container.json")
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
var container *Container
|
||||
if err := json.NewDecoder(f).Decode(&container); err != nil {
|
||||
t.Fatal("failed to decode container config")
|
||||
}
|
||||
if container.Hostname != "koye" {
|
||||
t.Log("hostname is not set")
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if !container.Tty {
|
||||
t.Log("tty should be set to true")
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if !container.Namespaces.Contains("NEWNET") {
|
||||
t.Log("namespaces should contain NEWNET")
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if container.Namespaces.Contains("NEWUSER") {
|
||||
t.Log("namespaces should not contain NEWUSER")
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if !container.CapabilitiesMask.Contains("SYS_ADMIN") {
|
||||
t.Log("capabilities mask should contain SYS_ADMIN")
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if container.CapabilitiesMask.Get("SYS_ADMIN").Enabled {
|
||||
t.Log("SYS_ADMIN should not be enabled in capabilities mask")
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if !container.CapabilitiesMask.Get("MKNOD").Enabled {
|
||||
t.Log("MKNOD should be enabled in capabilities mask")
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if container.CapabilitiesMask.Contains("SYS_CHROOT") {
|
||||
t.Log("capabilities mask should not contain SYS_CHROOT")
|
||||
t.Fail()
|
||||
}
|
||||
}
|
|
@ -57,7 +57,7 @@ func (ns *linuxNs) Exec(container *libcontainer.Container, term Terminal, args [
|
|||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
ns.logger.Printf("writting pid %d to file\n", command.Process.Pid)
|
||||
ns.logger.Printf("writing pid %d to file\n", command.Process.Pid)
|
||||
if err := ns.stateWriter.WritePid(command.Process.Pid, started); err != nil {
|
||||
command.Process.Kill()
|
||||
return -1, err
|
||||
|
|
|
@ -32,7 +32,7 @@ func main() {
|
|||
registerFlags()
|
||||
|
||||
if flag.NArg() < 1 {
|
||||
log.Fatalf("wrong number of argments %d", flag.NArg())
|
||||
log.Fatalf("wrong number of arguments %d", flag.NArg())
|
||||
}
|
||||
container, err := loadContainer()
|
||||
if err != nil {
|
||||
|
@ -73,7 +73,7 @@ func main() {
|
|||
l.Fatal(err)
|
||||
}
|
||||
if flag.NArg() < 2 {
|
||||
l.Fatalf("wrong number of argments %d", flag.NArg())
|
||||
l.Fatalf("wrong number of arguments %d", flag.NArg())
|
||||
}
|
||||
syncPipe, err := nsinit.NewSyncPipeFromFd(0, uintptr(pipeFd))
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue