qvm-features-request: ensure qrexec agent is started

Prevents:

Traceback (most recent call last):
  File "/usr/bin/qvm-features-request", line 81, in <module>
    sys.exit(main())
  File "/usr/bin/qvm-features-request", line 78, in main
    stdin=devnull, stdout=devnull)
  File "/usr/lib/python3.7/subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['qrexec-client-vm', 'dom0', 'qubes.FeaturesRequest']' returned non-zero exit status 127.

and

Traceback (most recent call last):
  File "/usr/bin/qvm-features-request", line 81, in <module>
    sys.exit(main())
  File "/usr/bin/qvm-features-request", line 70, in main
    qdb = qubesdb.QubesDB()
qubesdb.Error: (2, 'No such file or directory')

Fixes QubesOS/qubes-issues#4469
This commit is contained in:
Frédéric Pierret (fepitre) 2021-05-07 11:39:33 +02:00
parent a8ab8d4eff
commit 5805941daf
No known key found for this signature in database
GPG Key ID: 484010B5CDC576E2

View File

@ -29,6 +29,12 @@ import sys
import qubesdb
def is_active(service):
status = subprocess.call(["systemctl", "is-active", "--quiet", service])
return status == 0
class FeatureRequestAction(argparse.Action):
'''Action for argument parser that stores a property.'''
# pylint: disable=redefined-builtin,too-few-public-methods
@ -66,7 +72,8 @@ parser.add_argument('features',
def main(args=None):
args = parser.parse_args(args)
if not is_active("qubes-qrexec-agent"):
return
qdb = qubesdb.QubesDB()
for feature, value in args.features.items():
qdb.write('/features-request/' + feature, value)