Skip to content

Commit 06fd5a0

Browse files
committed
Fix handling long application names in qubes.StartApp service
Application names longer than 37 chars don't fit in qubesdb name limit for app-dispvm service entry. Switch to using hash of the name, which has a constant length. Encode SHA256 of the name using URL-safe base64 (instead of hex) to save some length. And since those entries are generated automatically, move them out of /qubes-service/ qubesdb tree (into /hash-app-dispvm/), to not interfere with manual entries. Fixes QubesOS/qubes-issues#7421
1 parent 9af5c38 commit 06fd5a0

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

qubes-rpc/qubes.StartApp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/python3 --
22

33
import sys, os, pwd
4+
import hashlib
5+
import base64
46
import qubesdb
57
from qubesagent.xdg import launch
68
from xdg.BaseDirectory import xdg_data_dirs
@@ -12,7 +14,22 @@ def main(argv):
1214
print('This service requires an argument', file=sys.stderr)
1315
sys.exit(1)
1416
qubes_db = qubesdb.QubesDB()
15-
if qubes_db.read('/qubes-service/app-dispvm.' + arg) is not None:
17+
# replace default file handlers to open files in disposables
18+
force_open_dvm = False
19+
arg_hash = (
20+
base64.urlsafe_b64encode(hashlib.sha256(arg.encode()).digest())
21+
.decode()
22+
.rstrip("=")
23+
)
24+
if qubes_db.read("/hash-app-dispvm/" + arg_hash) == arg:
25+
force_open_dvm = True
26+
# legacy entry, for short app names only
27+
if (
28+
len(arg) <= 37
29+
and qubes_db.read("/qubes-service/app-dispvm." + arg) is not None
30+
):
31+
force_open_dvm = True
32+
if force_open_dvm:
1633
for bad_var in ('XDG_DATA_HOME', 'GNOME_DESKTOP_SESSION_ID'):
1734
try:
1835
del os.environ[bad_var]

0 commit comments

Comments
 (0)