Quellcode durchsuchen

qubespolicy: implement --just-evaluate and --assume-yes-for-ask options

Those were registered in the parser, but ignored otherwise. The main
(and only?) purpose of them is to evaluate policy when pasting some text
between domains.

Fixes QubesOS/qubes-issues#2985
Marek Marczykowski-Górecki vor 6 Jahren
Ursprung
Commit
b3c92c475a
1 geänderte Dateien mit 8 neuen und 0 gelöschten Zeilen
  1. 8 0
      qubespolicy/cli.py

+ 8 - 0
qubespolicy/cli.py

@@ -66,6 +66,14 @@ def main(args=None):
     try:
         policy = qubespolicy.Policy(args.service_name)
         action = policy.evaluate(system_info, args.domain, args.target)
+        if args.assume_yes_for_ask and action.action == qubespolicy.Action.ask:
+            action.action = qubespolicy.Action.allow
+        if args.just_evaluate:
+            return {
+                qubespolicy.Action.allow: 0,
+                qubespolicy.Action.deny: 1,
+                qubespolicy.Action.ask: 1,
+            }[action.action]
         if action.action == qubespolicy.Action.ask:
             # late import to save on time for allow/deny actions
             import pydbus