Skip to content

Commit

Permalink
Merge pull request #53 from jaredbancroft/jb_idtools
Browse files Browse the repository at this point in the history
use docker idtools for subid lookups
  • Loading branch information
AkihiroSuda authored Mar 25, 2019
2 parents bc7c3a3 + e2a5df0 commit 3dd3e52
Show file tree
Hide file tree
Showing 130 changed files with 10,890 additions and 20 deletions.
59 changes: 57 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
name = "github.com/opencontainers/runc"
branch = "master"

[[override]]
name = "github.com/docker/docker"
branch = "master"

[prune]
go-tests = true
unused-packages = true
52 changes: 34 additions & 18 deletions pkg/parent/parent.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import (
"net/http"
"os"
"os/exec"
"os/user"
"path/filepath"
"strconv"
"syscall"


"github.com/docker/docker/pkg/idtools"
"github.com/gorilla/mux"
"github.com/opencontainers/runc/libcontainer/user"
"github.com/pkg/errors"
"github.com/theckman/go-flock"

Expand Down Expand Up @@ -172,55 +173,70 @@ func Parent(opt Opt) error {
}

func newuidmapArgs() ([]string, error) {
u, err := user.CurrentUser()
u, err := user.Current()
if err != nil {
return nil, err
}
res := []string{
"0",
strconv.Itoa(u.Uid),
u.Uid,
"1",
}
subs, err := user.CurrentUserSubUIDs()

//get both subid maps
//uses username for groupname in case primary groupname is not the same
//idtools will fall back to getent if /etc/passwd does not contain username
//works with external auth, ie sssd, ldap, nis
ims, err := idtools.NewIdentityMapping(u.Username, u.Username)
if err != nil {
return nil, err
}
// TODO: continue with non-subuid on ENOENT maybe

// TODO: continue with non-subgid on ENOENT maybe
last := 1
for _, sub := range subs {
for _, im := range ims.UIDs() {
res = append(res, []string{
strconv.Itoa(last),
strconv.Itoa(int(sub.SubID)),
strconv.Itoa(int(sub.Count)),
strconv.Itoa(im.HostID),
strconv.Itoa(im.Size),
}...)
last += int(sub.Count)
}
last += im.Size
}
return res, nil
}

func newgidmapArgs() ([]string, error) {
g, err := user.CurrentGroup()
u, err := user.Current()
if err != nil {
return nil, err
}
//g, err := user.LookupGroupId(u.Gid)
if err != nil {
return nil, err
}
res := []string{
"0",
strconv.Itoa(g.Gid),
u.Gid,
"1",
}
subs, err := user.CurrentUserSubGIDs()

//get both subid maps
//uses username for groupname in case primary groupname is not the same
//idtools will fall back to getent if /etc/group does not contain group name
//works with external auth, ie sssd, ldap, nis
ims, err := idtools.NewIdentityMapping(u.Username, u.Username)
if err != nil {
return nil, err
}
// TODO: continue with non-subgid on ENOENT maybe
last := 1
for _, sub := range subs {
for _, im := range ims.GIDs() {
res = append(res, []string{
strconv.Itoa(last),
strconv.Itoa(int(sub.SubID)),
strconv.Itoa(int(sub.Count)),
strconv.Itoa(im.HostID),
strconv.Itoa(im.Size),
}...)
last += int(sub.Count)
last += int(im.Size)
}
return res, nil
}
Expand Down
1 change: 1 addition & 0 deletions vendor/github.com/Microsoft/go-winio/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions vendor/github.com/Microsoft/go-winio/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions vendor/github.com/Microsoft/go-winio/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions vendor/github.com/Microsoft/go-winio/archive/tar/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3dd3e52

Please sign in to comment.