mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
libct: simplify Caps inheritance
For all other properties that are available in both Config and Process, the merging is performed by newInitConfig. Let's do the same for Capabilities for the sake of code uniformity. Also, thanks to the previous commit, we no longer have to make sure we do not call capabilities.New(nil). Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -700,7 +700,7 @@ func (c *Container) newInitConfig(process *Process) *initConfig {
|
||||
GID: process.GID,
|
||||
AdditionalGroups: process.AdditionalGroups,
|
||||
Cwd: process.Cwd,
|
||||
Capabilities: process.Capabilities,
|
||||
Capabilities: c.config.Capabilities,
|
||||
PassedFilesCount: len(process.ExtraFiles),
|
||||
ContainerID: c.ID(),
|
||||
NoNewPrivileges: c.config.NoNewPrivileges,
|
||||
@@ -714,6 +714,9 @@ func (c *Container) newInitConfig(process *Process) *initConfig {
|
||||
|
||||
// Overwrite config properties with ones from process.
|
||||
|
||||
if process.Capabilities != nil {
|
||||
cfg.Capabilities = process.Capabilities
|
||||
}
|
||||
if process.NoNewPrivileges != nil {
|
||||
cfg.NoNewPrivileges = *process.NoNewPrivileges
|
||||
}
|
||||
|
||||
@@ -322,13 +322,7 @@ func finalizeNamespace(config *initConfig) error {
|
||||
}
|
||||
}
|
||||
|
||||
caps := &configs.Capabilities{}
|
||||
if config.Capabilities != nil {
|
||||
caps = config.Capabilities
|
||||
} else if config.Config.Capabilities != nil {
|
||||
caps = config.Config.Capabilities
|
||||
}
|
||||
w, err := capabilities.New(caps)
|
||||
w, err := capabilities.New(config.Capabilities)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user