Skip to content

Commit

Permalink
fix permission denied
Browse files Browse the repository at this point in the history
when exec as root and config.Cwd is not owned by root, exec will fail
because root doesn't have the caps.

So, Chdir should be done before setting the caps.
  • Loading branch information
win-t committed Jul 17, 2019
1 parent 6cccc17 commit 84fd582
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libcontainer/init_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ func finalizeNamespace(config *initConfig) error {
if err := system.ClearKeepCaps(); err != nil {
return errors.Wrap(err, "clear keep caps")
}
if err := w.ApplyCaps(); err != nil {
return errors.Wrap(err, "apply caps")
}
if config.Cwd != "" {
if err := unix.Chdir(config.Cwd); err != nil {
return fmt.Errorf("chdir to cwd (%q) set in config.json failed: %v", config.Cwd, err)
}
}
if err := w.ApplyCaps(); err != nil {
return errors.Wrap(err, "apply caps")
}
return nil
}

Expand Down

0 comments on commit 84fd582

Please sign in to comment.