mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #5449 from tianon/remove-libcontainer-root-special-case
Remove "root" and "" special cases in libcontainer
This commit is contained in:
commit
eb6a1c9f49
1 changed files with 12 additions and 25 deletions
|
@ -83,31 +83,18 @@ func (ns *linuxNs) Init(container *libcontainer.Container, uncleanRootfs, consol
|
|||
}
|
||||
|
||||
func setupUser(container *libcontainer.Container) error {
|
||||
switch container.User {
|
||||
case "root", "":
|
||||
if err := system.Setgroups(nil); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := system.Setresgid(0, 0, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := system.Setresuid(0, 0, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
uid, gid, suppGids, err := user.GetUserGroupSupplementary(container.User, syscall.Getuid(), syscall.Getgid())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := system.Setgroups(suppGids); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := system.Setgid(gid); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := system.Setuid(uid); err != nil {
|
||||
return err
|
||||
}
|
||||
uid, gid, suppGids, err := user.GetUserGroupSupplementary(container.User, syscall.Getuid(), syscall.Getgid())
|
||||
if err != nil {
|
||||
return fmt.Errorf("GetUserGroupSupplementary %s", err)
|
||||
}
|
||||
if err := system.Setgroups(suppGids); err != nil {
|
||||
return fmt.Errorf("setgroups %s", err)
|
||||
}
|
||||
if err := system.Setgid(gid); err != nil {
|
||||
return fmt.Errorf("setgid %s", err)
|
||||
}
|
||||
if err := system.Setuid(uid); err != nil {
|
||||
return fmt.Errorf("setuid %s", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue