Skip to content

Commit

Permalink
test: restricted.devices.disk project restrictions
Browse files Browse the repository at this point in the history
Signed-off-by: Wesley Hershberger <[email protected]>
  • Loading branch information
MggMuggins committed Sep 3, 2024
1 parent 5ebca77 commit 29dd916
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/suites/projects.sh
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,28 @@ test_projects_restrictions() {
lxc project set p1 restricted.devices.disk=block
! lxc profile device add default data disk pool="${pool}" path=/mnt source="v-proj$$" || false

restrictedDir="/opt/projects_restricted"
mkdir "${restrictedDir}"
tmpDir=$(mktemp -d)
optDir=$(mktemp -d --tmpdir="${restrictedDir}")

# Block unmanaged disk devices
lxc project set p1 restricted.devices.disk=managed
! lxc profile device add default data disk path=/mnt source="${tmpDir}" || false

# Allow unmanaged disk devices
lxc project set p1 restricted.devices.disk=allow
lxc profile device add default data disk path=/mnt source="${tmpDir}"
lxc profile device remove default data

# Path restrictions
lxc project set p1 restricted.devices.disk.paths="${restrictedDir}"
! lxc profile device add default data disk path=/mnt source="${tmpDir}" || false
lxc profile device add default data disk path=/mnt source="${optDir}"
lxc profile device remove default data

rm -r "${tmpDir}" "${optDir}" "${restrictedDir}"

# Setting restricted.containers.nesting to 'allow' makes it possible to create
# nested containers.
lxc project set p1 restricted.containers.nesting=allow
Expand Down

0 comments on commit 29dd916

Please sign in to comment.