aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArif Ali <arif.ali@canonical.com>2024-02-09 19:54:52 +0000
committerJake Hunsaker <jacob.r.hunsaker@gmail.com>2024-02-10 16:28:02 -0500
commitdb3f4cf56bb8f8782ada99df64f435decf5c99fa (patch)
tree2f0eb274a06b583aefe443319fb4707126043792
parent18bf20a36da02d55a0499f9bfabf83a9eecc86b0 (diff)
downloadsos-db3f4cf56bb8f8782ada99df64f435decf5c99fa.tar.gz
[lxd] Fix predicate for lxc commands collection for snap
The list of modules was too broad, and depending on the different attributes configured the list of modules to be loaded could also be different. Liaising with the LXD team suggested to check for the `snap.lxd.daemon` service rather then the modules to collect `lxd.buginfo`. This is due to the fact that LXD is socket activated, and running any lxd based command could start the service and hence load the modules. Gating this with either the `snap.lxd.daemon` for snap or `lxd` service for debs respectively should prevent this from happening. This also no obfuscates the certificate that is retrieved from `lxd.buginfo` Resolves: SET-377 Signed-off-by: Arif Ali <arif.ali@canonical.com>
-rw-r--r--sos/report/plugins/lxd.py30
1 files changed, 10 insertions, 20 deletions
diff --git a/sos/report/plugins/lxd.py b/sos/report/plugins/lxd.py
index 994092e8..6df20dff 100644
--- a/sos/report/plugins/lxd.py
+++ b/sos/report/plugins/lxd.py
@@ -18,31 +18,16 @@ class LXD(Plugin, UbuntuPlugin):
profiles = ('container',)
packages = ('lxd',)
commands = ('lxc', 'lxd',)
+ services = ('snap.lxd.daemon', 'snap.lxd.activate')
def setup(self):
- lxd_kmods = [
- 'bpfilter',
- 'ebtable_filter',
- 'ebtables',
- 'ip6table_filter',
- 'ip6table_mangle',
- 'ip6table_nat',
- 'ip6table_raw',
- 'ip6_tables',
- 'iptable_filter',
- 'iptable_mangle',
- 'iptable_nat',
- 'iptable_raw',
- 'nf_nat',
- 'nf_tables',
- ]
-
- lxd_pred = SoSPredicate(self, kmods=lxd_kmods,
- required={'kmods': 'all'})
-
lxd_pkg = self.policy.package_manager.pkg_by_name('lxd')
if lxd_pkg and lxd_pkg['pkg_manager'] == 'snap':
+
+ lxd_pred = SoSPredicate(self, services=['snap.lxd.daemon'],
+ required={'services': 'all'})
+
self.add_cmd_output("lxd.buginfo", pred=lxd_pred)
self.add_copy_spec([
@@ -62,6 +47,8 @@ class LXD(Plugin, UbuntuPlugin):
'/var/snap/lxd/common/lxd/logs/**',
])
else:
+ lxd_pred = SoSPredicate(self, services=['lxd'],
+ required={'services': 'all'})
self.add_copy_spec([
"/etc/default/lxd-bridge",
"/var/log/lxd/*"
@@ -79,4 +66,7 @@ class LXD(Plugin, UbuntuPlugin):
"find /var/lib/lxd -maxdepth 2 -type d -ls",
], suggest_filename='var-lxd-dirs.txt')
+ def postproc(self):
+ self.do_cmd_private_sub('lxd.buginfo')
+
# vim: set et ts=4 sw=4 :