Skip to main content

org.osbuild.idmap

Recursively apply idmaps on all items in a given path

Stage to change the ownership of directories and files recursively by shifting the UID and GID based on an given idmapping. The mapping can be defined by

  • using the same syntax as the X-mount.idmap from mount(8)
  • using a user/group name from the subordinate files

The syntax based on the X-mount.idmap from mount(8) looks like this: id-type:id-mount:id-host:id-range

The id-type prefix specifies if the mapping is applied to UID, GID or both and can take the following values:

  • u: only UIDs are mapped
  • g: only GIDs are mapped
  • b: UIDs and GIDs are mapped Omitting the id-type prefix is synonym to using b.

The id-host parameter specifies the current ID in the file system. The id-mount parameter specifies the starting ID to which the id-host gets mapped to. The id-range parameter indicates how many IDs are to be mapped.

For example, the following configuration would map UIDs and GIDs of all files and directories in /usr/lib/qm/rootfs:

type: org.osbuild.idmap options: items: /usr/lib/qm/rootfs:

  • 'b:1000:0:10'

A file a owned by user 0:0 (UID:GID) would be changed to be owned by user 1000:1000. The ownership of a file b initially owned by user 1:1 would transition to user 1001:1001. And so on. If a file z is owned by user 20:20, however, then a mapping user 65534 (nobody) is applied.

By using a user/group name, a lookup to the current /etc/subuid and /etc/subgid is made searching for the specified names. If found, the ID ranges will be parsed and always mapped to the host-id 0 (root).

Schema 1

{
"additionalProperties": false,
"properties": {
"items": {
"type": "object",
"description": "Paths to apply the idmapping for",
"additionalProperties": false,
"patternProperties": {
"^\\/(?!\\.\\.)((?!\\/\\.\\.\\/).)+$": {
"oneOf": [
{
"type": "array",
"description": "List of idmaps to recursively apply to all items in the given path",
"minItems": 1,
"items": {
"type": "string",
"pattern": "^(?:(?:u|g|b):)?[0-9]+:[0-9]+:[1-9][0-9]*$"
}
},
{
"type": "object",
"description": "Use the idmapping form the subordinate ID configuration of a user/group",
"additionalProperties": false,
"required": [
"user",
"group"
],
"properties": {
"user": {
"type": "string",
"description": "User in /etc/subuid to use for the idmapping",
"minLength": 1
},
"group": {
"type": "string",
"description": "Group in /etc/subgid to use for the idmapping",
"minLength": 1
}
}
}
]
}
}
}
}
}

Schema 2

{}