Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 85 additions & 5 deletions image/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,92 @@ func (c *config) runtimeSpec(rootfs string) (*specs.Spec, error) {
return nil, fmt.Errorf("%s: unsupported OS", c.OS)
}

var s specs.Spec
s.Version = specs.Version
// we should at least apply the default spec, otherwise this is totally useless
s.Process.Terminal = true
// TODO: Get this default from somewhere, rather than hardcoding it here.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest you get the default from a vendored runtime-tools/generate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up implementing cyphar/umoci#13 so I'll probably end up just merging that here and dropping the old code.

// runC has a default as well, maybe the two should be consolidated in the
// runtime-spec (or in the runtime-tooling)?
s := specs.Spec{
Version: specs.Version,
Platform: specs.Platform{
OS: "unknown",
Arch: "unknown",
},
Process: specs.Process{
Terminal: true,
Cwd: "/",
Env: []string{},
Args: []string{},
User: specs.User{
UID: 0,
GID: 0,
},
},
Root: specs.Root{
Path: "rootfs",
Readonly: false,
},
// These are all required by the runtime-spec to be included. The
// actual options are from the default runC spec.
Mounts: []specs.Mount{
{
Destination: "/proc",
Type: "proc",
Source: "proc",
Options: nil,
},
{
Destination: "/sys",
Type: "sysfs",
Source: "sysfs",
Options: []string{"nosuid", "noexec", "nodev", "ro"},
},
{
Destination: "/dev",
Type: "tmpfs",
Source: "tmpfs",
Options: []string{"nosuid", "strictatime", "mode=755", "size=65536k"},
},
{
Destination: "/dev/pts",
Type: "devpts",
Source: "devpts",
Options: []string{"nosuid", "noexec", "newinstance", "ptmxmode=0666", "mode=0620", "gid=5"},
},
{
Destination: "/dev/shm",
Type: "tmpfs",
Source: "shm",
Options: []string{"nosuid", "noexec", "nodev", "mode=1777", "size=65536k"},
},
},
Linux: &specs.Linux{
MaskedPaths: []string{
"/proc/kcore",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/sys/firmware",
},
ReadonlyPaths: []string{
"/proc/asound",
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger",
},
// We need at least CLONE_NEWNS in order to set up the mounts.
// This is also required to make sure we have a sane rootfs setup.
Namespaces: []specs.Namespace{
{
Type: "mount",
},
},
},
}

// Now fill all of the fields.
s.Root.Path = rootfs
s.Process.Cwd = "/"
if c.Config.WorkingDir != "" {
s.Process.Cwd = c.Config.WorkingDir
}
Expand Down