Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce requirements.privileged #182

Merged
merged 5 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/api-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2271,3 +2271,7 @@ no effect on existing devices.
This API extension indicates that the `/1.0/operations/{id}/wait` endpoint exists on the server. This indicates to the client
that the endpoint can be used to wait for an operation to complete rather than waiting for an operation event via the
`/1.0/events` endpoint.

## `image_restriction_privileged`

This extension adds a new image restriction, `requirements.privileged` which when `false` indicates that an image cannot be run in a privileged container.
3 changes: 2 additions & 1 deletion doc/image-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ The following requirements are supported:

Key | Type | Default | Description
:-- | :--- | :------ | :----------
`requirements.secureboot` | string | - | If set to `false`, indicates that the image cannot boot under secure boot.
`requirements.cgroup` | string | - | If set to `v1`, indicates that the image requires the host to run cgroup v1.
`requirements.privileged` | bool | - | If set to `false`, indicates that the image cannot work as a privileged container.
`requirements.secureboot` | bool | - | If set to `false`, indicates that the image cannot boot under secure boot.
5 changes: 5 additions & 0 deletions internal/server/instance/drivers/driver_lxc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1916,6 +1916,11 @@ func (d *lxc) startCommon() (string, []func() error, error) {
return "", nil, fmt.Errorf("The image used by this instance requires a CGroupV1 host system")
}

// Ensure privileged is turned off for images that cannot work privileged
if util.IsFalse(d.localConfig["image.requirements.privileged"]) && util.IsTrue(d.expandedConfig["security.privileged"]) {
return "", nil, fmt.Errorf("The image used by this instance is incompatible with privileged containers. Please unset security.privileged on the instance")
}

// Load any required kernel modules
kernelModules := d.expandedConfig["linux.kernel_modules"]
if kernelModules != "" {
Expand Down
1 change: 1 addition & 0 deletions internal/version/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ var APIExtensions = []string{
"instances_nic_limits_priority",
"disk_initial_volume_configuration",
"operation_wait",
"image_restriction_privileged",
}

// APIExtensionsCount returns the number of available API extensions.
Expand Down
Loading