Add support for retrieving LUKS UUIDs.
---
cryptodev.py | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/cryptodev.py b/cryptodev.py
index 080d198..a651625 100644
--- a/cryptodev.py
+++ b/cryptodev.py
@@ -38,6 +38,17 @@ def isLuks(device):
else:
return True
+def luksUUID(device):
+ if not device.startswith("/"):
+ device = "/dev/" + device
+
+ if not isLuks(device):
+ return None
+
+ uuid = iutil.execWithCapture("cryptsetup", ["luksUUID", device])
+ uuid = uuid.strip()
+ return uuid
+
class LUKSDevice:
"""LUKSDevice represents an encrypted block device using LUKS/dm-crypt.
It requires an underlying block device and a passphrase to become
@@ -46,6 +57,7 @@ class LUKSDevice:
self._device = None
self.passphrase = ""
self.name = ""
+ self.uuid = None
self.nameLocked = False
self.format = format
self.preexist = not format
@@ -82,6 +94,17 @@ class LUKSDevice:
return dev
+ def getUUID(self):
+ if self.format:
+ # self.format means we're going to reformat but haven't yet
+ # so we shouldn't act like there's anything worth seeing there
+ return
+
+ if not self.uuid:
+ self.uuid = luksUUID(self.getDevice(encrypted=1))
+
+ return self.uuid
+
def setName(self, name, lock=False):
"""Set the name of the mapped device, eg: 'dmcrypt-sda3'"""
if self.name == name:
--
1.5.4.1
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
|