Ensure all dev nodes are copied for privileged
This also makes sure that devices are pointers to avoid copies Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
parent
000552944e
commit
084c621c66
6 changed files with 231 additions and 221 deletions
|
@ -4,7 +4,6 @@ package nodes
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
|
@ -14,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
// Create the device nodes in the container.
|
||||
func CreateDeviceNodes(rootfs string, nodesToCreate []devices.Device) error {
|
||||
func CreateDeviceNodes(rootfs string, nodesToCreate []*devices.Device) error {
|
||||
oldMask := system.Umask(0000)
|
||||
defer system.Umask(oldMask)
|
||||
|
||||
|
@ -27,7 +26,7 @@ func CreateDeviceNodes(rootfs string, nodesToCreate []devices.Device) error {
|
|||
}
|
||||
|
||||
// Creates the device node in the rootfs of the container.
|
||||
func CreateDeviceNode(rootfs string, node devices.Device) error {
|
||||
func CreateDeviceNode(rootfs string, node *devices.Device) error {
|
||||
var (
|
||||
dest = filepath.Join(rootfs, node.Path)
|
||||
parent = filepath.Dir(dest)
|
||||
|
@ -52,27 +51,3 @@ func CreateDeviceNode(rootfs string, node devices.Device) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getDeviceNodes(path string) ([]string, error) {
|
||||
out := []string{}
|
||||
files, err := ioutil.ReadDir(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, f := range files {
|
||||
if f.IsDir() && f.Name() != "pts" && f.Name() != "shm" {
|
||||
sub, err := getDeviceNodes(filepath.Join(path, f.Name()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out = append(out, sub...)
|
||||
} else if f.Mode()&os.ModeDevice == os.ModeDevice {
|
||||
out = append(out, filepath.Join(path, f.Name()))
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func GetHostDeviceNodes() ([]string, error) {
|
||||
return getDeviceNodes("/dev")
|
||||
}
|
||||
|
|
|
@ -7,10 +7,6 @@ import (
|
|||
"github.com/dotcloud/docker/pkg/libcontainer/devices"
|
||||
)
|
||||
|
||||
func GetHostDeviceNodes() ([]string, error) {
|
||||
return nil, libcontainer.ErrUnsupported
|
||||
}
|
||||
|
||||
func CreateDeviceNodes(rootfs string, nodesToCreate []devices.Device) error {
|
||||
func CreateDeviceNodes(rootfs string, nodesToCreate []*devices.Device) error {
|
||||
return libcontainer.ErrUnsupported
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue