Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use docker idtools for subid lookups #53

Merged
merged 1 commit into from
Mar 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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