Skip to content
This repository has been archived by the owner on Apr 21, 2021. It is now read-only.

Commit

Permalink
runtimetest: fix uid_map parsing
Browse files Browse the repository at this point in the history
The fields of /proc/$pid/uid_map and /proc/$pid/gid_map were parsed in
the wrong order.

Related: opencontainers/runtime-spec#956

Signed-off-by: Alban Crequy <alban@kinvolk.io>
  • Loading branch information
alban committed Mar 8, 2018
1 parent fdbc3d6 commit 4e999f2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/runtimetest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,11 +632,13 @@ func getIDMappings(path string) ([]rspec.LinuxIDMapping, error) {

idMap := strings.Fields(strings.TrimSpace(s.Text()))
if len(idMap) == 3 {
hostID, err := strconv.ParseUint(idMap[0], 0, 32)
// "man 7 user_namespaces" explains the format of uid_map and gid_map:
// <containerID> <hostID> <mapSize>
containerID, err := strconv.ParseUint(idMap[0], 0, 32)
if err != nil {
return nil, err
}
containerID, err := strconv.ParseUint(idMap[1], 0, 32)
hostID, err := strconv.ParseUint(idMap[1], 0, 32)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 4e999f2

Please sign in to comment.