fix: more fixes
This commit is contained in:
23 files changed
+207
-146
No files matched your search
@@ -5,6 +5,7 @@ validation, permission errors and systemd triggers stay in one place, and its
|
||||
die() cannot take a front end down.
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
@@ -176,7 +177,8 @@ def outbound_rows(_):
|
||||
excluded = set(inventory.get("excluded") or [])
|
||||
current = ctl._outbound_current()
|
||||
reputation = ctl._reputation_by_tag()
|
||||
runtime = set(ctl._runtime_tags("outbound"))
|
||||
# outbounds.d is root-only; the inventory says "runtime" for what the backend loaded from it.
|
||||
runtime = set(ctl._runtime_tags("outbound")) | {t for t, s in sources.items() if s == "runtime"}
|
||||
return [
|
||||
{
|
||||
"key": t,
|
||||
@@ -567,6 +569,21 @@ def elevated(argv, via):
|
||||
return [via, shutil.which(CTL) or CTL, *argv]
|
||||
|
||||
|
||||
def load_tab_as_root(tab, via):
|
||||
"""load_tab in proxy-ctl run through via (pkexec): (rows, summary), or None and why it did not run."""
|
||||
try:
|
||||
p = subprocess.run(elevated(["status", "--tab", tab.id], via), capture_output=True, text=True, stdin=subprocess.DEVNULL)
|
||||
except OSError as e:
|
||||
return None, f"cannot run {via}: {e}"
|
||||
if p.returncode in (126, 127) and not p.stdout and not p.stderr.strip():
|
||||
return None, "authentication cancelled" # pkexec: dismissed, or not allowed
|
||||
try:
|
||||
rows, summary = json.loads(p.stdout)
|
||||
return rows, summary
|
||||
except ValueError:
|
||||
return None, (p.stderr.strip().splitlines() or [f"exit status {p.returncode}"])[-1]
|
||||
|
||||
|
||||
def popen(argv, root=None):
|
||||
"""proxy-ctl with its output streamed: its own process group, so stop() takes down what it spawned too.
|
||||
root: "pkexec" to run it as root, asking through the desktop's polkit agent."""
|
||||
|
||||
Reference in new issue
Block a user