From fe271c5672afdb136edb15d1717b54f60c315992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 19 Feb 2018 02:26:02 +0100 Subject: [PATCH] qubespolicy: use '@' instead of '$' for policy keywords Using '$' is easy to misuse in shell scripts, shell commands etc. After all this years, lets abandon this dangerous character and move to something safer: '@'. The choice was made after reviewing specifications of various shells on different operating systems and this is the character that have no special meaning in none of them. To preserve compatibility, automatically translate '$' to '@' when loading policy files. --- qrexec/qrexec-policy | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/qrexec/qrexec-policy b/qrexec/qrexec-policy index 15921f7..db6dde4 100755 --- a/qrexec/qrexec-policy +++ b/qrexec/qrexec-policy @@ -63,6 +63,7 @@ def read_policy_file(service_name): f = open(policy_file) fcntl.flock(f, fcntl.LOCK_SH) for iter in f.readlines(): + iter = iter.replace('$', '@') dict = line_to_dict(iter) if dict is not None: policy_list.append(dict) @@ -70,7 +71,7 @@ def read_policy_file(service_name): return policy_list def is_match(item, config_term): - return (item != "dom0" and config_term == "$anyvm") or item == config_term + return (item != "dom0" and config_term == "@anyvm") or item == config_term def get_default_policy(): dict={} @@ -89,7 +90,7 @@ def find_policy(policy, domain, target): def validate_target(target): # special targets - if target in ['$dispvm']: + if target in ['@dispvm']: return True qc = QubesVmCollection() @@ -110,7 +111,7 @@ def spawn_target_if_necessary(vm): null.close() def do_execute(domain, target, user, service_name, process_ident, vm=None): - if target == "$dispvm": + if target == "@dispvm": cmd = "/usr/lib/qubes/qfile-daemon-dvm " + service_name + " " + domain + " " +user os.execl(QREXEC_CLIENT, "qrexec-client", "-d", "dom0", "-c", process_ident, cmd) @@ -179,11 +180,11 @@ def create_policy(service_name): policyFile = "/etc/qubes-rpc/policy/"+service_name policy = open(policyFile, "w") policy.write("## Note that policy parsing stops at the first match,\n") - policy.write("## so adding anything below \"$anyvm $anyvm action\" line will have no effect\n") + policy.write("## so adding anything below \"@anyvm @anyvm action\" line will have no effect\n") policy.write("\n") policy.write("## Please use a single # to start your custom comments\n") policy.write("\n") - policy.write("$anyvm $anyvm ask\n") + policy.write("@anyvm @anyvm ask\n") policy.close() def main():