storage/lvm: fix reporting lvm command error

Escape '%' in error message, as required by Admin API.

Fixes QubesOS/qubes-issues#3809
This commit is contained in:
Marek Marczykowski-Górecki 2018-04-13 15:57:09 +02:00
parent 94c8e25d3c
commit 2aa14623bf
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -574,6 +574,7 @@ def qubes_lvm(cmd, log=logging.getLogger('qubes.storage.lvm')):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
close_fds=True, env=environ)
out, err = p.communicate()
err = err.decode()
return_code = p.returncode
if out:
log.debug(out)
@ -581,6 +582,7 @@ def qubes_lvm(cmd, log=logging.getLogger('qubes.storage.lvm')):
log.warning(err)
elif return_code != 0:
assert err, "Command exited unsuccessful, but printed nothing to stderr"
err = err.replace('%', '%%')
raise qubes.storage.StoragePoolException(err)
return True