|
|
fce3c4 |
From 86e6843a61758fc17b13286c0c928efb97d15227 Mon Sep 17 00:00:00 2001
|
|
|
fce3c4 |
From: Pavel Moravec <pmoravec@redhat.com>
|
|
|
fce3c4 |
Date: Sat, 28 Jul 2018 09:45:49 +0200
|
|
|
fce3c4 |
Subject: [PATCH] [block] collect luksDump for all encrypted devices
|
|
|
fce3c4 |
|
|
|
fce3c4 |
Call "cryptsetup luksDump /dev/sd*" for all encrypted devices
|
|
|
fce3c4 |
|
|
|
fce3c4 |
Resolves: #1390
|
|
|
fce3c4 |
|
|
|
fce3c4 |
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
|
|
|
fce3c4 |
---
|
|
|
fce3c4 |
sos/plugins/block.py | 22 ++++++++++++++++++++++
|
|
|
fce3c4 |
1 file changed, 22 insertions(+)
|
|
|
fce3c4 |
|
|
|
fce3c4 |
diff --git a/sos/plugins/block.py b/sos/plugins/block.py
|
|
|
fce3c4 |
index 3a2d14d3..059686c5 100644
|
|
|
fce3c4 |
--- a/sos/plugins/block.py
|
|
|
fce3c4 |
+++ b/sos/plugins/block.py
|
|
|
fce3c4 |
@@ -19,6 +19,22 @@ class Block(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
|
|
|
fce3c4 |
verify_packages = ('util-linux',)
|
|
|
fce3c4 |
files = ('/sys/block',)
|
|
|
fce3c4 |
|
|
|
fce3c4 |
+ def get_luks_devices(self, lsblk_file):
|
|
|
fce3c4 |
+ out = []
|
|
|
fce3c4 |
+ try:
|
|
|
fce3c4 |
+ lsblk_out = open(lsblk_file).read()
|
|
|
fce3c4 |
+ except IOError:
|
|
|
fce3c4 |
+ return out
|
|
|
fce3c4 |
+ for line in lsblk_out.splitlines():
|
|
|
fce3c4 |
+ # find in output lines like
|
|
|
fce3c4 |
+ # |-sda2 crypto_LUKS <uuid>
|
|
|
fce3c4 |
+ # and separate device name - it will be 1st string on the line
|
|
|
fce3c4 |
+ # after first '-'
|
|
|
fce3c4 |
+ if 'crypto_LUKS' in line:
|
|
|
fce3c4 |
+ dev = line.split()[0].split('-', 1)[1]
|
|
|
fce3c4 |
+ out.append(dev)
|
|
|
fce3c4 |
+ return out
|
|
|
fce3c4 |
+
|
|
|
fce3c4 |
def setup(self):
|
|
|
fce3c4 |
self.add_cmd_output([
|
|
|
fce3c4 |
"lsblk",
|
|
|
fce3c4 |
@@ -51,4 +67,10 @@ class Block(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
|
|
|
fce3c4 |
"fdisk -l %s" % disk_path
|
|
|
fce3c4 |
])
|
|
|
fce3c4 |
|
|
|
fce3c4 |
+ lsblk_file = self.get_cmd_output_now("lsblk -f -a")
|
|
|
fce3c4 |
+ # for LUKS devices, collect cryptsetup luksDump
|
|
|
fce3c4 |
+ if lsblk_file:
|
|
|
fce3c4 |
+ for dev in self.get_luks_devices(lsblk_file):
|
|
|
fce3c4 |
+ self.add_cmd_output('cryptsetup luksDump /dev/%s' % dev)
|
|
|
fce3c4 |
+
|
|
|
fce3c4 |
# vim: set et ts=4 sw=4 :
|
|
|
fce3c4 |
--
|
|
|
fce3c4 |
2.17.1
|
|
|
fce3c4 |
|