diff options
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r-- | libpod/container_internal.go | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 79bc49c37..c88794212 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -926,6 +926,9 @@ func (c *Container) makeBindMounts() error { if err != nil { return errors.Wrapf(err, "error creating resolv.conf for container %s", c.ID()) } + if err = label.Relabel(newResolv, c.config.MountLabel, false); err != nil { + return errors.Wrapf(err, "error relabeling %q for container %q", newResolv, c.ID) + } c.state.BindMounts["/etc/resolv.conf"] = newResolv // Make /etc/hosts @@ -937,6 +940,9 @@ func (c *Container) makeBindMounts() error { if err != nil { return errors.Wrapf(err, "error creating hosts file for container %s", c.ID()) } + if err = label.Relabel(newHosts, c.config.MountLabel, false); err != nil { + return errors.Wrapf(err, "error relabeling %q for container %q", newHosts, c.ID) + } c.state.BindMounts["/etc/hosts"] = newHosts // Make /etc/hostname @@ -946,6 +952,9 @@ func (c *Container) makeBindMounts() error { if err != nil { return errors.Wrapf(err, "error creating hostname file for container %s", c.ID()) } + if err = label.Relabel(hostnamePath, c.config.MountLabel, false); err != nil { + return errors.Wrapf(err, "error relabeling %q for container %q", hostnamePath, c.ID) + } c.state.BindMounts["/etc/hostname"] = hostnamePath } @@ -1246,7 +1255,7 @@ func (c *Container) saveSpec(spec *spec.Spec) error { } func (c *Container) setupOCIHooks(ctx context.Context, config *spec.Spec) (extensionStageHooks map[string][]spec.Hook, err error) { - if c.runtime.config.HooksDir == "" { + if len(c.runtime.config.HooksDir) == 0 { return nil, nil } @@ -1277,16 +1286,25 @@ func (c *Container) setupOCIHooks(ctx context.Context, config *spec.Spec) (exten } } - manager, err := hooks.New(ctx, []string{c.runtime.config.HooksDir}, []string{"poststop"}, lang) - if err != nil { - if c.runtime.config.HooksDirNotExistFatal || !os.IsNotExist(err) { + var allHooks map[string][]spec.Hook + for _, hDir := range c.runtime.config.HooksDir { + manager, err := hooks.New(ctx, []string{hDir}, []string{"poststop"}, lang) + if err != nil { + if c.runtime.config.HooksDirNotExistFatal || !os.IsNotExist(err) { + return nil, err + } + logrus.Warnf("failed to load hooks: {}", err) + return nil, nil + } + hooks, err := manager.Hooks(config, c.Spec().Annotations, len(c.config.UserVolumes) > 0) + if err != nil { return nil, err } - logrus.Warnf("failed to load hooks: {}", err) - return nil, nil + for i, hook := range hooks { + allHooks[i] = hook + } } - - return manager.Hooks(config, c.Spec().Annotations, len(c.config.UserVolumes) > 0) + return allHooks, nil } // mount mounts the container's root filesystem |