mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Update daemon to use moby sys/user identity mapping
Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
@@ -119,6 +119,31 @@ type IdentityMapping struct {
|
||||
GIDMaps []IDMap `json:"GIDMaps"`
|
||||
}
|
||||
|
||||
// FromUserIdentityMapping converts a [user.IdentityMapping] to an [idtools.IdentityMapping].
|
||||
//
|
||||
// Deprecated: use [user.IdentityMapping] directly, this is transitioning to user package.
|
||||
func FromUserIdentityMapping(u user.IdentityMapping) IdentityMapping {
|
||||
return IdentityMapping{
|
||||
UIDMaps: fromUserIDMap(u.UIDMaps),
|
||||
GIDMaps: fromUserIDMap(u.GIDMaps),
|
||||
}
|
||||
}
|
||||
|
||||
func fromUserIDMap(u []user.IDMap) []IDMap {
|
||||
if u == nil {
|
||||
return nil
|
||||
}
|
||||
m := make([]IDMap, len(u))
|
||||
for i := range u {
|
||||
m[i] = IDMap{
|
||||
ContainerID: int(u[i].ID),
|
||||
HostID: int(u[i].ParentID),
|
||||
Size: int(u[i].Count),
|
||||
}
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
// RootPair returns a uid and gid pair for the root user. The error is ignored
|
||||
// because a root user always exists, and the defaults are correct when the uid
|
||||
// and gid maps are empty.
|
||||
|
||||
Reference in New Issue
Block a user