Skip to content

Commit

Permalink
Revert "Validate service names"
Browse files Browse the repository at this point in the history
Conditions checked here are bogus (the only relevant one is length).
Furthermore it's done in wrong place (should be pre- event).

This reverts commit a3aea50.

Fixes QubesOS/qubes-issues#9274
  • Loading branch information
marmarek committed May 31, 2024
1 parent fe51d74 commit 0ec452e
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions qubes/ext/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,28 +88,13 @@ def on_domain_feature_set(self, vm, event, feature, value, oldvalue=None):
# balancing state anymore
del vm.features['service.meminfo-writer']

if not vm.is_running():
return
if not feature.startswith('service.'):
return
service = feature[len('service.'):]
# qubesdb keys are limited to 63 bytes, and "/qubes-service/" is
# 15 bytes. That leaves 48 for the service name.
if len(service) > 48:
raise qubes.exc.QubesValueError(
'Service name must not exceed 48 bytes')
# The empty string is not a valid file name.
if not service:
raise qubes.exc.QubesValueError('Empty service name not allowed')
# Require service names to start with an ASCII letter. This implicitly
# rejects names which start with '-' (which could be interpreted as an
# option) or are '.' or '..'.
if not (('a' <= service[0] <= 'z') or ('A' <= service[0] <= 'Z')):
raise qubes.exc.QubesValueError(
'Service name must start with an ASCII letter')

if not vm.is_running():
return
# forcefully convert to '0' or '1'
vm.untrusted_qdb.write('/qubes-service/' + service,
vm.untrusted_qdb.write('/qubes-service/{}'.format(service),
str(int(bool(value))))

if vm.name == "dom0":
Expand Down

0 comments on commit 0ec452e

Please sign in to comment.