Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 60ef4ae

Browse files
committed
Update libcontainer to 4a72e540feb67091156b907c4700e580a99f5a9d
Signed-off-by: Mrunal Patel <[email protected]>
1 parent 831c796 commit 60ef4ae

11 files changed

Lines changed: 139 additions & 35 deletions

File tree

daemon/execdriver/native/template/default_template.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,26 @@ func New() *configs.Config {
4040
AllowAllDevices: false,
4141
},
4242
Mounts: []*configs.Mount{
43+
{
44+
Source: "proc",
45+
Destination: "/proc",
46+
Device: "proc",
47+
Flags: defaultMountFlags,
48+
},
49+
{
50+
Source: "tmpfs",
51+
Destination: "/dev",
52+
Device: "tmpfs",
53+
Flags: syscall.MS_NOSUID | syscall.MS_STRICTATIME,
54+
Data: "mode=755",
55+
},
56+
{
57+
Source: "devpts",
58+
Destination: "/dev/pts",
59+
Device: "devpts",
60+
Flags: syscall.MS_NOSUID | syscall.MS_NOEXEC,
61+
Data: "newinstance,ptmxmode=0666,mode=0620,gid=5",
62+
},
4363
{
4464
Device: "tmpfs",
4565
Source: "shm",

hack/vendor.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ rm -rf src/github.com/docker/distribution
7575
mkdir -p src/github.com/docker/distribution
7676
mv tmp-digest src/github.com/docker/distribution/digest
7777

78-
clone git github.com/docker/libcontainer 52a8c004ca94cf98f6866536de828c71eb42d1ec
78+
clone git github.com/docker/libcontainer 4a72e540feb67091156b907c4700e580a99f5a9d
7979
# see src/github.com/docker/libcontainer/update-vendor.sh which is the "source of truth" for libcontainer deps (just like this file)
8080
rm -rf src/github.com/docker/libcontainer/vendor
8181
eval "$(grep '^clone ' src/github.com/docker/libcontainer/update-vendor.sh | grep -v 'github.com/codegangsta/cli' | grep -v 'github.com/Sirupsen/logrus')"

vendor/src/github.com/coreos/go-systemd/activation/listeners.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func Listeners(unsetEnv bool) ([]net.Listener, error) {
3030
var err error
3131
listeners[i], err = net.FileListener(f)
3232
if err != nil {
33-
return nil, fmt.Errorf("Error setting up FileListener for fd %d: %v", f.Fd(), err)
33+
return nil, fmt.Errorf("Error setting up FileListener for fd %d: %s", f.Fd(), err.Error())
3434
}
3535
}
3636

vendor/src/github.com/docker/libcontainer/container.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ type Container interface {
9696
//
9797
// errors:
9898
// Systemerror - System error.
99-
Set() error
99+
Set(config configs.Config) error
100100

101101
// Start a process inside the container. Returns error if process fails to
102102
// start. You can track process lifecycle with passed Process structure.

vendor/src/github.com/docker/libcontainer/container_linux.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ func (c *linuxContainer) Stats() (*Stats, error) {
7878
return stats, nil
7979
}
8080

81-
func (c *linuxContainer) Set() error {
81+
func (c *linuxContainer) Set(config configs.Config) error {
8282
c.m.Lock()
8383
defer c.m.Unlock()
84+
c.config = &config
8485
return c.cgroupManager.Set(c.config)
8586
}
8687

vendor/src/github.com/docker/libcontainer/factory_linux.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import (
1010
"os/exec"
1111
"path/filepath"
1212
"regexp"
13+
"syscall"
1314

15+
"github.com/docker/docker/pkg/mount"
1416
"github.com/docker/libcontainer/cgroups"
1517
"github.com/docker/libcontainer/cgroups/fs"
1618
"github.com/docker/libcontainer/cgroups/systemd"
@@ -78,6 +80,20 @@ func Cgroupfs(l *LinuxFactory) error {
7880
return nil
7981
}
8082

83+
// TmpfsRoot is an option func to mount LinuxFactory.Root to tmpfs.
84+
func TmpfsRoot(l *LinuxFactory) error {
85+
mounted, err := mount.Mounted(l.Root)
86+
if err != nil {
87+
return err
88+
}
89+
if !mounted {
90+
if err := syscall.Mount("tmpfs", l.Root, "tmpfs", 0, ""); err != nil {
91+
return err
92+
}
93+
}
94+
return nil
95+
}
96+
8197
// New returns a linux based container factory based in the root directory and
8298
// configures the factory with the provided option funcs.
8399
func New(root string, options ...func(*LinuxFactory) error) (Factory, error) {

vendor/src/github.com/docker/libcontainer/factory_linux_test.go

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"path/filepath"
1010
"testing"
1111

12+
"github.com/docker/docker/pkg/mount"
1213
"github.com/docker/libcontainer/configs"
1314
)
1415

@@ -17,9 +18,6 @@ func newTestRoot() (string, error) {
1718
if err != nil {
1819
return "", err
1920
}
20-
if err := os.MkdirAll(dir, 0700); err != nil {
21-
return "", err
22-
}
2321
return dir, nil
2422
}
2523

@@ -49,6 +47,58 @@ func TestFactoryNew(t *testing.T) {
4947
}
5048
}
5149

50+
func TestFactoryNewTmpfs(t *testing.T) {
51+
root, rerr := newTestRoot()
52+
if rerr != nil {
53+
t.Fatal(rerr)
54+
}
55+
defer os.RemoveAll(root)
56+
factory, err := New(root, Cgroupfs, TmpfsRoot)
57+
if err != nil {
58+
t.Fatal(err)
59+
}
60+
if factory == nil {
61+
t.Fatal("factory should not be nil")
62+
}
63+
lfactory, ok := factory.(*LinuxFactory)
64+
if !ok {
65+
t.Fatal("expected linux factory returned on linux based systems")
66+
}
67+
if lfactory.Root != root {
68+
t.Fatalf("expected factory root to be %q but received %q", root, lfactory.Root)
69+
}
70+
71+
if factory.Type() != "libcontainer" {
72+
t.Fatalf("unexpected factory type: %q, expected %q", factory.Type(), "libcontainer")
73+
}
74+
mounted, err := mount.Mounted(lfactory.Root)
75+
if err != nil {
76+
t.Fatal(err)
77+
}
78+
if !mounted {
79+
t.Fatalf("Factory Root is not mounted")
80+
}
81+
mounts, err := mount.GetMounts()
82+
if err != nil {
83+
t.Fatal(err)
84+
}
85+
var found bool
86+
for _, m := range mounts {
87+
if m.Mountpoint == lfactory.Root {
88+
if m.Fstype != "tmpfs" {
89+
t.Fatalf("Fstype of root: %s, expected %s", m.Fstype, "tmpfs")
90+
}
91+
if m.Source != "tmpfs" {
92+
t.Fatalf("Source of root: %s, expected %s", m.Source, "tmpfs")
93+
}
94+
found = true
95+
}
96+
}
97+
if !found {
98+
t.Fatalf("Factory Root is not listed in mounts list")
99+
}
100+
}
101+
52102
func TestFactoryLoadNotExists(t *testing.T) {
53103
root, rerr := newTestRoot()
54104
if rerr != nil {

vendor/src/github.com/docker/libcontainer/integration/template_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,26 @@ func newTemplateConfig(rootfs string) *configs.Config {
6060
Devices: configs.DefaultAutoCreatedDevices,
6161
Hostname: "integration",
6262
Mounts: []*configs.Mount{
63+
{
64+
Source: "proc",
65+
Destination: "/proc",
66+
Device: "proc",
67+
Flags: defaultMountFlags,
68+
},
69+
{
70+
Source: "tmpfs",
71+
Destination: "/dev",
72+
Device: "tmpfs",
73+
Flags: syscall.MS_NOSUID | syscall.MS_STRICTATIME,
74+
Data: "mode=755",
75+
},
76+
{
77+
Source: "devpts",
78+
Destination: "/dev/pts",
79+
Device: "devpts",
80+
Flags: syscall.MS_NOSUID | syscall.MS_NOEXEC,
81+
Data: "newinstance,ptmxmode=0666,mode=0620,gid=5",
82+
},
6383
{
6484
Device: "tmpfs",
6585
Source: "shm",

vendor/src/github.com/docker/libcontainer/nsinit/config.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,26 @@ func getTemplate() *configs.Config {
234234
"/proc/sys", "/proc/sysrq-trigger", "/proc/irq", "/proc/bus",
235235
},
236236
Mounts: []*configs.Mount{
237+
{
238+
Source: "proc",
239+
Destination: "/proc",
240+
Device: "proc",
241+
Flags: defaultMountFlags,
242+
},
243+
{
244+
Source: "tmpfs",
245+
Destination: "/dev",
246+
Device: "tmpfs",
247+
Flags: syscall.MS_NOSUID | syscall.MS_STRICTATIME,
248+
Data: "mode=755",
249+
},
250+
{
251+
Source: "devpts",
252+
Destination: "/dev/pts",
253+
Device: "devpts",
254+
Flags: syscall.MS_NOSUID | syscall.MS_NOEXEC,
255+
Data: "newinstance,ptmxmode=0666,mode=0620,gid=5",
256+
},
237257
{
238258
Device: "tmpfs",
239259
Source: "shm",

vendor/src/github.com/docker/libcontainer/rootfs_linux.go

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,14 @@ import (
1717

1818
const defaultMountFlags = syscall.MS_NOEXEC | syscall.MS_NOSUID | syscall.MS_NODEV
1919

20-
var baseMounts = []*configs.Mount{
21-
{
22-
Source: "proc",
23-
Destination: "/proc",
24-
Device: "proc",
25-
Flags: defaultMountFlags,
26-
},
27-
{
28-
Source: "tmpfs",
29-
Destination: "/dev",
30-
Device: "tmpfs",
31-
Flags: syscall.MS_NOSUID | syscall.MS_STRICTATIME,
32-
Data: "mode=755",
33-
},
34-
{
35-
Source: "devpts",
36-
Destination: "/dev/pts",
37-
Device: "devpts",
38-
Flags: syscall.MS_NOSUID | syscall.MS_NOEXEC,
39-
Data: "newinstance,ptmxmode=0666,mode=0620,gid=5",
40-
},
41-
}
42-
4320
// setupRootfs sets up the devices, mount points, and filesystems for use inside a
4421
// new mount namespace.
4522
func setupRootfs(config *configs.Config, console *linuxConsole) (err error) {
4623
if err := prepareRoot(config); err != nil {
4724
return newSystemError(err)
4825
}
49-
for _, m := range append(baseMounts, config.Mounts...) {
50-
if err := mount(m, config.Rootfs, config.MountLabel); err != nil {
26+
for _, m := range config.Mounts {
27+
if err := mountToRootfs(m, config.Rootfs, config.MountLabel); err != nil {
5128
return newSystemError(err)
5229
}
5330
}
@@ -85,7 +62,7 @@ func setupRootfs(config *configs.Config, console *linuxConsole) (err error) {
8562
return nil
8663
}
8764

88-
func mount(m *configs.Mount, rootfs, mountLabel string) error {
65+
func mountToRootfs(m *configs.Mount, rootfs, mountLabel string) error {
8966
var (
9067
dest = m.Destination
9168
data = label.FormatMountLabel(m.Data, mountLabel)

0 commit comments

Comments
 (0)