Prompt to create policy file for qubes-rpc if not present.
This commit is contained in:
parent
9ea58a2ce2
commit
194e0bc3cc
@ -148,8 +148,9 @@ def add_always_allow(domain, target, service_name, options):
|
|||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def info_dialog(msg_type, text):
|
def info_dialog(msg_type, text):
|
||||||
if msg_type not in ['info', 'warning', 'error']:
|
if msg_type not in ['info', 'warning', 'error', 'entry']:
|
||||||
raise ValueError("Invalid msg_type value")
|
raise ValueError("Invalid msg_type value")
|
||||||
|
if msg_type in ['info', 'warning', 'error']:
|
||||||
try:
|
try:
|
||||||
subprocess.call(["/usr/bin/zenity", "--{}".format(msg_type), "--text",
|
subprocess.call(["/usr/bin/zenity", "--{}".format(msg_type), "--text",
|
||||||
text])
|
text])
|
||||||
@ -159,13 +160,31 @@ def info_dialog(msg_type, text):
|
|||||||
'warning': 'sorry',
|
'warning': 'sorry',
|
||||||
'error': 'error'
|
'error': 'error'
|
||||||
}[msg_type]
|
}[msg_type]
|
||||||
subprocess.call(["/usr/bin/kdialog", "--{}".format(kdialog_msg_type),
|
subprocess.call(["/usr/bin/kdialog", "--{}".format(kdialog_msg_type), text])
|
||||||
|
else:
|
||||||
|
response = subprocess.check_output(["/usr/bin/zenity", "--{}".format(msg_type), "--text",
|
||||||
text])
|
text])
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
def policy_editor(domain, target, service_name):
|
def policy_editor(domain, target, service_name):
|
||||||
text = "No policy definition found for " + service_name + " action. "
|
text = "No policy definition found for " + service_name + " action. \n"
|
||||||
text+= "Please create a policy file in Dom0 in " + POLICY_FILE_DIR + "/" + service_name
|
text+= "Type YES if you want to create a default policy file"
|
||||||
info_dialog("warning", text)
|
response = info_dialog('entry', text)
|
||||||
|
if response.strip() == 'YES':
|
||||||
|
create_policy(service_name)
|
||||||
|
|
||||||
|
|
||||||
|
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("\n")
|
||||||
|
policy.write("## Please use a single # to start your custom comments\n")
|
||||||
|
policy.write("\n")
|
||||||
|
policy.write("$anyvm $anyvm ask\n")
|
||||||
|
policy.close()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
usage = "usage: %prog [options] <src-domain-id> <src-domain> <target-domain> <service> <process-ident>"
|
usage = "usage: %prog [options] <src-domain-id> <src-domain> <target-domain> <service> <process-ident>"
|
||||||
|
Loading…
Reference in New Issue
Block a user