diff options
author | David Lehman <dlehman@redhat.com> | 2008-03-26 13:08:23 -0500 |
---|---|---|
committer | David Lehman <dlehman@redhat.com> | 2008-03-28 11:14:39 -0500 |
commit | 953bad6b7870255c962ef36b1e172a05fd3db6c5 (patch) | |
tree | dec0e988c999cdd4877ff87866ecdd29e04e75df | |
parent | b4af3d40091d6f1e481a1aadb37271b4f503a687 (diff) | |
download | anaconda-953bad6b7870255c962ef36b1e172a05fd3db6c5.tar.gz anaconda-953bad6b7870255c962ef36b1e172a05fd3db6c5.tar.xz anaconda-953bad6b7870255c962ef36b1e172a05fd3db6c5.zip |
Add support for retrieving LUKS UUIDs.
-rw-r--r-- | cryptodev.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/cryptodev.py b/cryptodev.py index 080d198b6..a651625af 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: |