Skip to content

Commit

Permalink
Merge pull request #1880 from AkihiroSuda/fix-subgid
Browse files Browse the repository at this point in the history
libcontainer: CurrentGroupSubGIDs -> CurrentUserSubGIDs
  • Loading branch information
crosbymichael authored Oct 16, 2018
2 parents 78ef28e + b34d6d8 commit 58592df
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions libcontainer/user/lookup_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package user
import (
"io"
"os"
"strconv"

"golang.org/x/sys/unix"
)
Expand Down Expand Up @@ -115,22 +116,23 @@ func CurrentGroup() (Group, error) {
return LookupGid(unix.Getgid())
}

func CurrentUserSubUIDs() ([]SubID, error) {
func currentUserSubIDs(fileName string) ([]SubID, error) {
u, err := CurrentUser()
if err != nil {
return nil, err
}
return ParseSubIDFileFilter("/etc/subuid",
func(entry SubID) bool { return entry.Name == u.Name })
filter := func(entry SubID) bool {
return entry.Name == u.Name || entry.Name == strconv.Itoa(u.Uid)
}
return ParseSubIDFileFilter(fileName, filter)
}

func CurrentGroupSubGIDs() ([]SubID, error) {
g, err := CurrentGroup()
if err != nil {
return nil, err
}
return ParseSubIDFileFilter("/etc/subgid",
func(entry SubID) bool { return entry.Name == g.Name })
func CurrentUserSubUIDs() ([]SubID, error) {
return currentUserSubIDs("/etc/subuid")
}

func CurrentUserSubGIDs() ([]SubID, error) {
return currentUserSubIDs("/etc/subgid")
}

func CurrentProcessUIDMap() ([]IDMap, error) {
Expand Down

0 comments on commit 58592df

Please sign in to comment.