FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora User

 
 
LinkBack Thread Tools
 
Old 02-01-2008, 06:04 PM
David Lehman
 
Default Add ability to scan encrypted devices for fstype, labels, and root filesystems.

---
partedUtils.py | 91 +++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 73 insertions(+), 18 deletions(-)

diff --git a/partedUtils.py b/partedUtils.py
index f047a2f..7166027 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -680,10 +680,17 @@ class DiskSet:
parts = filter_partitions(disk, func)
for part in parts:
node = get_partition_name(part)
+ crypto = self.anaconda.id.partitions.encryptedDevices.get(n ode)
+ if crypto and not crypto.openDevice():
+ node = crypto.getDevice()
+
label = isys.readFSLabel(node)
if label:
labels[node] = label

+ if crypto:
+ crypto.closeDevice()
+
# not doing this right now, because we should _always_ have a
# partition table of some kind on dmraid.
if False:
@@ -693,10 +700,17 @@ class DiskSet:
labels[rs.name] = label

for dev, devices, level, numActive in DiskSet.mdList:
+ crypto = self.anaconda.id.partitions.encryptedDevices.get(d ev)
+ if crypto and not crypto.openDevice():
+ dev = crypto.getDevice()
+
label = isys.readFSLabel(dev)
if label:
labels[dev] = label

+ if crypto:
+ crypto.closeDevice()
+
active = lvm.vgcheckactive()
if not active:
lvm.vgscan()
@@ -706,10 +720,17 @@ class DiskSet:
if lvorigin:
continue
node = "%s/%s" % (vg, lv)
+ crypto = self.anaconda.id.partitions.encryptedDevices.get(n ode)
+ if crypto and not crypto.openDevice():
+ node = crypto.getDevice()
+
label = isys.readFSLabel("/dev/" + node)
if label:
labels[node] = label

+ if crypto:
+ crypto.closeDevice()
+
if not active:
lvm.vgdeactivate()

@@ -723,16 +744,28 @@ class DiskSet:
self.startDmRaid()
self.startMdRaid()

+ for dev, crypto in self.anaconda.id.partitions.encryptedDevices.items ():
+ # FIXME: order these so LVM and RAID always work on the first try
+ if crypto.openDevice():
+ log.error("failed to open encrypted device %s" % (dev,))
+
if flags.cmdline.has_key("upgradeany"):
upgradeany = 1

for dev, devices, level, numActive in self.mdList:
(errno, msg) = (None, None)
found = 0
- fs = isys.readFSType(dev)
+ theDev = dev
+ crypto = self.anaconda.id.partitions.encryptedDevices.get(d ev)
+ if crypto and not crypto.openDevice():
+ theDev = "/dev/%s" % (crypto.getDevice(),)
+ elif crypto:
+ log.error("failed to open encrypted device %s" % dev)
+
+ fs = isys.readFSType(theDev)
if fs is not None:
try:
- isys.mount(dev, self.anaconda.rootPath, fs, readOnly = 1)
+ isys.mount(theDev, self.anaconda.rootPath, fs, readOnly = 1)
found = 1
except SystemError, (errno, msg):
pass
@@ -744,11 +777,12 @@ class DiskSet:
if ((upgradeany == 1) or
(productMatches(relstr, productName))):
try:
- label = isys.readFSLabel(dev)
+ label = isys.readFSLabel(theDev)
except:
label = None

- rootparts.append ((dev, fs, relstr, label))
+ # XXX we could add the "raw" dev and let caller decrypt
+ rootparts.append ((theDev, fs, relstr, label))
isys.umount(self.anaconda.rootPath)

# now, look for candidate lvm roots
@@ -760,10 +794,18 @@ class DiskSet:
continue
dev = "/dev/%s/%s" %(vg, lv)
found = 0
- fs = isys.readFSType(dev)
+ theDev = dev
+ node = "%s/%s" % (vg, lv)
+ crypto = self.anaconda.id.partitions.encryptedDevices.get(n ode)
+ if crypto and not crypto.openDevice():
+ theDev = "/dev/%s" % (crypto.getDevice(),)
+ elif crypto:
+ log.error("failed to open encrypted device %s" % dev)
+
+ fs = isys.readFSType(theDev)
if fs is not None:
try:
- isys.mount(dev, self.anaconda.rootPath, fs, readOnly = 1)
+ isys.mount(theDev, self.anaconda.rootPath, fs, readOnly = 1)
found = 1
except SystemError:
pass
@@ -775,11 +817,11 @@ class DiskSet:
if ((upgradeany == 1) or
(productMatches(relstr, productName))):
try:
- label = isys.readFSLabel(dev)
+ label = isys.readFSLabel(theDev)
except:
label = None

- rootparts.append ((dev, fs, relstr, label))
+ rootparts.append ((theDev, fs, relstr, label))
isys.umount(self.anaconda.rootPath)

lvm.vgdeactivate()
@@ -796,20 +838,34 @@ class DiskSet:
disk = self.disks[drive]
part = disk.next_partition ()
while part:
+ node = get_partition_name(part)
+ crypto = self.anaconda.id.partitions.encryptedDevices.get(n ode)
if (part.is_active()
and (part.get_flag(parted.PARTITION_RAID)
or part.get_flag(parted.PARTITION_LVM))):
- pass
- elif (part.fs_type and
- part.fs_type.name in fsset.getUsableLinuxFs()):
- node = get_partition_name(part)
+ part = disk.next_partition(part)
+ continue
+ elif part.fs_type or crypto:
+ theDev = node
+ if part.fs_type:
+ fstype = part.fs_type.name
+
+ if crypto and not crypto.openDevice():
+ theDev = crypto.getDevice()
+ fstype = isys.readFSType("/dev/%s" % theDev)
+ elif crypto:
+ log.error("failed to open encrypted device %s" % node)
+
+ if not fstype or fstype not in fsset.getUsableLinuxFs():
+ part = disk.next_partition(part)
+ continue

# The root filesystem can be on the same partition as the
# ISO images, but we don't want to try to remount it
# because that'll throw up a useless error message.
- if not protected or node not in protected:
+ if not protected or theDev not in protected:
try:
- isys.mount(node, self.anaconda.rootPath, part.fs_type.name)
+ isys.mount(theDev, self.anaconda.rootPath, part.fs_type.name)
checkRoot = self.anaconda.rootPath
except SystemError, (errno, msg):
part = disk.next_partition(part)
@@ -817,18 +873,17 @@ class DiskSet:
else:
checkRoot = self.anaconda.method.isoDir

- if os.access (checkRoot + '/etc/fstab', os.R_OK):
+ if os.access (checkRoot + '/etc/fstab', os.R_OK):
relstr = getReleaseString(checkRoot)

if ((upgradeany == 1) or
(productMatches(relstr, productName))):
try:
- label = isys.readFSLabel("/dev/%s" % node)
+ label = isys.readFSLabel("/dev/%s" % theDev)
except:
label = None

- rootparts.append ((node, part.fs_type.name,
- relstr, label))
+ rootparts.append ((theDev, fstype, relstr, label))

if not protected or node not in protected:
isys.umount(self.anaconda.rootPath)
--
1.5.3.7

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 01:26 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org