add apparmor:

Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
Victor Vieux 2014-09-29 23:34:45 +00:00
parent 87e732a0f3
commit c2c5e57a8e
5 changed files with 17 additions and 5 deletions

View file

@ -77,6 +77,7 @@ type Container struct {
daemon *Daemon
MountLabel, ProcessLabel string
AppArmorProfile string
RestartCount int
// Maps container paths to volume paths. The key in this is the path to which
@ -275,6 +276,7 @@ func populateCommand(c *Container, env []string) error {
ProcessLabel: c.GetProcessLabel(),
MountLabel: c.GetMountLabel(),
LxcConfig: lxcConfig,
AppArmorProfile: c.AppArmorProfile,
}
return nil

View file

@ -561,8 +561,16 @@ func (daemon *Daemon) newContainer(name string, config *runconfig.Config, img *i
for _, opt := range config.SecurityOpt {
con := strings.SplitN(opt, ":", 2)
if con[0] == "label" {
if len(con) == 1 {
return nil, fmt.Errorf("Invalid --security-opt: %q", opt)
}
switch con[0] {
case "label":
label_opts = append(label_opts, con[1])
case "apparmor":
container.AppArmorProfile = con[1]
default:
return nil, fmt.Errorf("Invalid --security-opt: %q", opt)
}
}

View file

@ -116,4 +116,5 @@ type Command struct {
ProcessLabel string `json:"process_label"`
MountLabel string `json:"mount_label"`
LxcConfig []string `json:"lxc_config"`
AppArmorProfile string `json:"apparmor_profile"`
}

View file

@ -409,10 +409,7 @@ func rootIsShared() bool {
}
func (d *driver) generateLXCConfig(c *execdriver.Command) (string, error) {
var (
root = path.Join(d.root, "containers", c.ID, "config.lxc")
label_opts []string
)
root := path.Join(d.root, "containers", c.ID, "config.lxc")
fo, err := os.Create(root)
if err != nil {

View file

@ -49,6 +49,10 @@ func (d *driver) createContainer(c *execdriver.Command) (*libcontainer.Config, e
}
}
if c.AppArmorProfile != "" {
container.AppArmorProfile = c.AppArmorProfile
}
if err := d.setupCgroups(container, c); err != nil {
return nil, err
}