Merge ~jslarraz/ubuntu-qa-tools:add-premissions-for-libvirt-qemu-user into ubuntu-qa-tools:master

Proposed by Jorge Sancho Larraz
Status: Merged
Merged at revision: 7e07fe17bcdc1809a4daed7e97e4a83131035aa6
Proposed branch: ~jslarraz/ubuntu-qa-tools:add-premissions-for-libvirt-qemu-user
Merge into: ubuntu-qa-tools:master
Diff against target: 37 lines (+26/-0)
1 file modified
vm-tools/uvt (+26/-0)
Reviewer Review Type Date Requested Status
Marc Deslauriers Approve
Review via email: mp+460694@code.launchpad.net

Commit message

uvt: grant libvirt-qemu search permissions on required directories

Description of the change

libvirt-qemu user requires search permissions all the way up vm_path and vm_dir_iso_cache. This uses setfacl to ensure that this requirement is met.

I'm just wondering if we also want to pronpt the user for this one

To post a comment you must log in.
Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Yeah, I think prompting the user is best here too, especially since these directories could be anywhere depending on what the user selected, and the use of extended acls isn't immediately obvious.

Revision history for this message
Jorge Sancho Larraz (jslarraz) wrote :
Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

LGTM, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/vm-tools/uvt b/vm-tools/uvt
2index 0095643..69538d4 100755
3--- a/vm-tools/uvt
4+++ b/vm-tools/uvt
5@@ -3554,6 +3554,32 @@ def load_uvt_config():
6 print("Creating '%s' directory..." % config[d])
7 os.makedirs(config[d])
8
9+ # Ensure libvirt-qemu user has search permissions all the way up the path
10+ # https://github.com/jedi4ever/veewee/issues/996
11+ path = config[d]
12+ while path != "/":
13+ rc, out = runcmd(["getfacl", "-e", path])
14+ if (not os.stat(path).st_mode & 0o001) and (re.search("user:libvirt-qemu:..x", out) is None):
15+
16+ print("Missing permissions found while creating '%s' directory. libvirt-qemu user "
17+ "requires search permission all the way up the path, but it seems to be"
18+ "missing on directory '%s'" % (d, path))
19+ print("If you wish to change the location where '%s' is "
20+ "stored, you can launch 'uvt config', which will create "
21+ "a default config file in ~/%s that you can customize. " % (d, config_file))
22+ print("")
23+ if not confirm("Would you like to grant libvirt-qemu search permissions on '%s'?" % path):
24+ print("Aborting.")
25+ sys.exit(1)
26+
27+ rc, out = runcmd(["setfacl", "-m", "u:libvirt-qemu:rx", path])
28+ if rc != 0:
29+ print("Error while granting libvirt-qemu search permissions on "
30+ "directory: '%s'. You can do it manully by issuing: " % path)
31+ print("setfacl -m u:libvirt-qemu:rx " + path)
32+
33+ path = os.path.abspath(os.path.join(path, os.pardir))
34+
35 conf_hash = hashlib.sha256((repr(sorted(config.items())).encode())).hexdigest()
36
37 return (config, conf_hash)

Subscribers

People subscribed via source and target branches