Skip to content

Commit

Permalink
ubuntu: Fix apparmor rule for podman preset
Browse files Browse the repository at this point in the history
On Ubuntu, crc's preflights add an apparmor rule to allow the use of
cacheDir/*/crc.qcow2 by libvirt. With podman bundles, the file is named
`crc-podman.qcow2`, which causes `crc start` to fail with permission
errors.
  • Loading branch information
cfergeau authored and praveenkumar committed Jun 29, 2022
1 parent 9f8df17 commit f844e5b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/crc/preflight/preflight_ubuntu_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func checkAppArmorExceptionIsPresent(reader reader) func() error {
}
}

// Add the exception `cacheDir/*/crc.qcow2 rk` in AppArmor template
// Add the exception `cacheDir/*/crc*.qcow2 rk` in AppArmor template
func addAppArmorExceptionForQcowDisks(reader reader, writer writer) func() error {
return replaceInAppArmorTemplate(reader, writer, appArmorHeader, expectedLines())
}
Expand All @@ -77,6 +77,6 @@ func replaceInAppArmorTemplate(reader reader, writer writer, before string, afte
}

func expectedLines() string {
line := fmt.Sprintf(" %s rk,", filepath.Join(constants.MachineCacheDir, "*", "crc.qcow2"))
line := fmt.Sprintf(" %s rk,", filepath.Join(constants.MachineCacheDir, "*", "crc*.qcow2"))
return fmt.Sprintf("%s\n%s\n", appArmorHeader, line)
}
2 changes: 1 addition & 1 deletion pkg/crc/preflight/preflight_ubuntu_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ profile LIBVIRT_TEMPLATE flags=(attach_disconnected) {
}`
expected = `#include <tunables/global>
profile LIBVIRT_TEMPLATE flags=(attach_disconnected) {
` + constants.MachineCacheDir + `/*/crc.qcow2 rk,
` + constants.MachineCacheDir + `/*/crc*.qcow2 rk,
#include <abstractions/libvirt-qemu>
}`
Expand Down

0 comments on commit f844e5b

Please sign in to comment.