qubespolicy: allow spaces in action arguments

This is natural to write space after coma.
This commit is contained in:
Marek Marczykowski-Górecki 2017-06-27 02:01:46 +02:00
parent 291a338e73
commit a937bb173a
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 5 additions and 4 deletions

View File

@ -121,11 +121,11 @@ class PolicyRule(object):
self.filename = filename self.filename = filename
try: try:
self.source, self.target, self.full_action = line.split() self.source, self.target, self.full_action = line.split(maxsplit=2)
except ValueError: except ValueError:
raise PolicySyntaxError(filename, lineno, 'wrong number of fields') raise PolicySyntaxError(filename, lineno, 'wrong number of fields')
(action, *params) = self.full_action.split(',') (action, *params) = self.full_action.replace(' ', '').split(',')
try: try:
self.action = Action[action] self.action = Action[action]
except KeyError: except KeyError:

View File

@ -155,6 +155,7 @@ class TC_00_PolicyRule(qubes.tests.QubesTestCase):
self.assertIsNone(line.default_target) self.assertIsNone(line.default_target)
def test_021_line_simple(self): def test_021_line_simple(self):
# also check spaces in action field
line = qubespolicy.PolicyRule( line = qubespolicy.PolicyRule(
'$tag:tag1 $type:AppVM ask, target=test-vm2, user=user', '$tag:tag1 $type:AppVM ask, target=test-vm2, user=user',
'filename', 12) 'filename', 12)