remappedGID reads the remapped GID 0 from the OCI spec, if it exists. If there is no remapping, remappedGID returns 0. If the spec cannot be parsed, remappedGID returns an error.
(spec []byte)
| 57 | // there is no remapping, remappedGID returns 0. If the spec cannot be parsed, |
| 58 | // remappedGID returns an error. |
| 59 | func remappedGID(spec []byte) (uint32, error) { |
| 60 | var ociSpec ociSpecUserNS |
| 61 | err := json.Unmarshal(spec, &ociSpec) |
| 62 | if err != nil { |
| 63 | return 0, err |
| 64 | } |
| 65 | if ociSpec.Linux == nil || len(ociSpec.Linux.GIDMappings) == 0 { |
| 66 | return 0, nil |
| 67 | } |
| 68 | for _, mapping := range ociSpec.Linux.GIDMappings { |
| 69 | if mapping.ContainerID == 0 { |
| 70 | return mapping.HostID, nil |
| 71 | } |
| 72 | } |
| 73 | return 0, nil |
| 74 | } |
searching dependent graphs…