aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2018-07-28 09:45:49 +0200
committerBryn M. Reeves <bmr@redhat.com>2018-08-23 15:09:44 +0100
commit86e6843a61758fc17b13286c0c928efb97d15227 (patch)
tree83fb8d87136ab565b5f996b8b9423c9e5da6dd7a
parentb30bf75847791d85d0e6e51a9b526b2bc93fc38e (diff)
downloadsos-86e6843a61758fc17b13286c0c928efb97d15227.tar.gz
[block] collect luksDump for all encrypted devices
Call "cryptsetup luksDump /dev/sd*" for all encrypted devices Resolves: #1390 Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
-rw-r--r--sos/plugins/block.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/sos/plugins/block.py b/sos/plugins/block.py
index 3a2d14d3..059686c5 100644
--- a/sos/plugins/block.py
+++ b/sos/plugins/block.py
@@ -19,6 +19,22 @@ class Block(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
verify_packages = ('util-linux',)
files = ('/sys/block',)
+ def get_luks_devices(self, lsblk_file):
+ out = []
+ try:
+ lsblk_out = open(lsblk_file).read()
+ except IOError:
+ return out
+ for line in lsblk_out.splitlines():
+ # find in output lines like
+ # |-sda2 crypto_LUKS <uuid>
+ # and separate device name - it will be 1st string on the line
+ # after first '-'
+ if 'crypto_LUKS' in line:
+ dev = line.split()[0].split('-', 1)[1]
+ out.append(dev)
+ return out
+
def setup(self):
self.add_cmd_output([
"lsblk",
@@ -51,4 +67,10 @@ class Block(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
"fdisk -l %s" % disk_path
])
+ lsblk_file = self.get_cmd_output_now("lsblk -f -a")
+ # for LUKS devices, collect cryptsetup luksDump
+ if lsblk_file:
+ for dev in self.get_luks_devices(lsblk_file):
+ self.add_cmd_output('cryptsetup luksDump /dev/%s' % dev)
+
# vim: set et ts=4 sw=4 :