Skip to content

Commit a61b46e

Browse files
committed
sosreport: Query sos policy for default tmp dir
sos 4.6.2 changed the tmp dir policy [1] from a static /var/tmp to a dynamic per-distro policy, which happens to be /tmp on Debian/Ubuntu right now. This is wrong, and there is no official way to query it [2]. To cope, query the sos policy for the tmp-dir, and only fall back to static /var/tmp if that fails. [1] sosreport/sos#4062 [2] sosreport/sos#4074
1 parent b217dbe commit a61b46e

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

pkg/sosreport/get_report_dir.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
import configparser
2+
import sys
23

34
c = configparser.ConfigParser()
45
c.read("/etc/sos/sos.conf")
56
try:
67
print(c["global"]["tmp-dir"])
78
except KeyError:
8-
print("/var/tmp")
9+
# very expensive and internal API, but there is no official way to get the tmp-dir
10+
# https://github.com/sosreport/sos/issues/4074
11+
try:
12+
import sos.policies
13+
print(sos.policies.load().get_tmp_dir(None))
14+
except Exception as e:
15+
# in case the API changes, sane fallback
16+
print("Failed to get policy tmp-dir:", e, file=sys.stderr)
17+
print("/var/tmp")

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ module = [
4141
# these are used from various scripts meant to run on the host
4242
"dbus",
4343
"tracer.query",
44+
"sos.*",
4445
"vdo.*",
4546
]
4647

0 commit comments

Comments
 (0)