summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYulia Poyarkova <ypoyarko@redhat.com>2008-03-27 01:55:44 +0000
committerYulia Poyarkova <ypoyarko@redhat.com>2008-03-27 01:55:44 +0000
commit2c6315da84bb405c5d4b79dc3c56be313145bb68 (patch)
treed81e30b826cc11aee1dceae565b315096fe38ad4
parentac9df6c55f44fec4292a93050f8cf6fb94a08f8f (diff)
parentd3b8e557c4de40e1c35936843090414dc056a683 (diff)
downloadanaconda-2c6315da84bb405c5d4b79dc3c56be313145bb68.tar.gz
anaconda-2c6315da84bb405c5d4b79dc3c56be313145bb68.tar.xz
anaconda-2c6315da84bb405c5d4b79dc3c56be313145bb68.zip
Merge branch 'master' of ssh://git.fedorahosted.org/git/anaconda
-rw-r--r--cryptodev.py11
-rw-r--r--fsset.py30
-rwxr-xr-xgui.py13
-rw-r--r--isys/imount.c4
-rw-r--r--iw/lvm_dialog_gui.py32
-rw-r--r--iw/task_gui.py5
-rw-r--r--kickstart.py3
-rw-r--r--livecd.py21
-rw-r--r--loader2/urls.c2
-rw-r--r--packages.py43
-rw-r--r--partRequests.py13
-rwxr-xr-xscripts/mk-images4
-rw-r--r--yuminstall.py24
13 files changed, 149 insertions, 56 deletions
diff --git a/cryptodev.py b/cryptodev.py
index 2cd14d784..080d198b6 100644
--- a/cryptodev.py
+++ b/cryptodev.py
@@ -62,10 +62,16 @@ class LUKSDevice:
return self.scheme
def setDevice(self, device):
+ if self._device == device:
+ return
+
self._device = device
if device is not None:
+ if device.startswith("/dev/"):
+ device = device[5:]
+
name = "%s-%s" % (self.scheme.lower(),
- os.path.basename(device))
+ device.replace("/", "-"))
self.setName(name)
def getDevice(self, encrypted=0):
@@ -78,6 +84,9 @@ class LUKSDevice:
def setName(self, name, lock=False):
"""Set the name of the mapped device, eg: 'dmcrypt-sda3'"""
+ if self.name == name:
+ return
+
if self.name and not self.getStatus():
raise RuntimeError, "Cannot rename an active mapping."
diff --git a/fsset.py b/fsset.py
index 6d6253e5b..92c7b5160 100644
--- a/fsset.py
+++ b/fsset.py
@@ -2019,7 +2019,11 @@ MAILADDR root
if not os.path.isdir(rootdir):
os.makedirs(rootdir)
- dmdev = "/dev/mapper/" + root.device.getDevice().replace("-","--").replace("/", "-")
+ if root.device.crypto is None:
+ dmdev = "/dev/mapper/" + root.device.getDevice().replace("-","--").replace("/", "-")
+ else:
+ dmdev = "/dev/" + root.device.getDevice()
+
if os.path.exists(instPath + dmdev):
os.unlink(instPath + dmdev)
if not os.path.isdir(os.path.dirname(instPath + dmdev)):
@@ -2027,11 +2031,13 @@ MAILADDR root
iutil.copyDeviceNode(dmdev, instPath + dmdev)
# unlink existing so that we dtrt on upgrades
- if os.path.exists(instPath + rootDev):
+ if os.path.exists(instPath + rootDev) and not root.device.crypto:
os.unlink(instPath + rootDev)
if not os.path.isdir(rootdir):
os.makedirs(rootdir)
- os.symlink(dmdev, instPath + rootDev)
+
+ if root.device.crypto is None:
+ os.symlink(dmdev, instPath + rootDev)
if not os.path.isdir("%s/etc/lvm" %(instPath,)):
os.makedirs("%s/etc/lvm" %(instPath,))
@@ -2508,8 +2514,8 @@ class VolumeGroupDevice(Device):
class LogicalVolumeDevice(Device):
# note that size is in megabytes!
- def __init__(self, vgname, size, lvname, vg, existing = 0):
- Device.__init__(self)
+ def __init__(self, vgname, size, lvname, vg, existing = 0, encryption=None):
+ Device.__init__(self, encryption=encryption)
self.vgname = vgname
self.size = size
self.name = lvname
@@ -2526,6 +2532,9 @@ class LogicalVolumeDevice(Device):
# self.readaheadsectors
def setupDevice(self, chroot="/", devPrefix='/dev', vgdevice = None):
+ if self.crypto:
+ self.crypto.setDevice("mapper/%s-%s" % (self.vgname, self.name))
+
if not self.isSetup:
lvm.lvcreate(self.name, self.vgname, self.size)
self.isSetup = 1
@@ -2533,10 +2542,19 @@ class LogicalVolumeDevice(Device):
if vgdevice and vgdevice.isNetdev():
self.setAsNetdev()
+ if self.crypto:
+ self.crypto.formatDevice()
+ self.crypto.openDevice()
+
return "/dev/%s" % (self.getDevice(),)
def getDevice(self, asBoot = 0):
- return "%s/%s" % (self.vgname, self.name)
+ if self.crypto and not asBoot:
+ device = self.crypto.getDevice()
+ else:
+ device = "%s/%s" % (self.vgname, self.name)
+
+ return device
def solidify(self):
return
diff --git a/gui.py b/gui.py
index a4f446fe8..d076b80b2 100755
--- a/gui.py
+++ b/gui.py
@@ -1382,6 +1382,17 @@ class InstallControlWindow:
gtk.main_quit()
os._exit(0)
+ def _doExitConfirm (self, win = None, *args):
+ # FIXME: translate the string
+ win = MessageWindow(_("Exit installer"),
+ ("Are you sure you wish to exit the installation?"),
+ type="custom", custom_icon="question",
+ custom_buttons = [_("Cancel"), _("_Exit installer")],
+ parent = win)
+ if win.getrc() == 0:
+ return True
+ self._doExit()
+
def createWidgets (self):
self.window.set_title(_("%s Installer") %(productName,))
@@ -1409,7 +1420,7 @@ class InstallControlWindow:
"on_backButton_clicked": self.prevClicked,
"on_debugButton_clicked": self.debugClicked,
"on_mainWindow_key_release_event": self.keyRelease,
- "on_mainWindow_delete_event": self._doExit, }
+ "on_mainWindow_delete_event": self._doExitConfirm, }
self.mainxml.signal_autoconnect(sigs)
def loadGlade(self):
diff --git a/isys/imount.c b/isys/imount.c
index 91201b7ec..0499b44de 100644
--- a/isys/imount.c
+++ b/isys/imount.c
@@ -49,8 +49,8 @@ int doPwMount(char *dev, char *where, char *fs, char *options) {
opts = strdup("nolock");
device = strdup(dev);
} else {
- if (strstr(options, "bind") == NULL && strncmp(dev, "LABEL=", 6) &&
- strncmp(dev, "UUID=", 5) && *dev != '/')
+ if ((options && strstr(options, "bind") == NULL) &&
+ strncmp(dev, "LABEL=", 6) && strncmp(dev, "UUID=", 5) && *dev != '/')
rc = asprintf(&device, "/dev/%s", dev);
else
device = strdup(dev);
diff --git a/iw/lvm_dialog_gui.py b/iw/lvm_dialog_gui.py
index 750258761..8bbb4a506 100644
--- a/iw/lvm_dialog_gui.py
+++ b/iw/lvm_dialog_gui.py
@@ -34,6 +34,7 @@ from partRequests import *
from partition_ui_helpers_gui import *
from constants import *
import lvm
+from cryptodev import LUKSDevice
import logging
log = logging.getLogger("anaconda")
@@ -472,6 +473,23 @@ class VolumeGroupEditor:
if logrequest.getPreExisting():
(row, self.fsoptionsDict) = createPreExistFSOptionSection(logrequest, maintable, row, mountCombo, self.partitions, ignorefs = ["software RAID", "physical volume (LVM)", "vfat"])
+ # checkbutton for encryption using dm-crypt/LUKS
+ if not logrequest.getPreExisting():
+ self.lukscb = gtk.CheckButton(_("_Encrypt"))
+ if logrequest.format or logrequest.type == REQUEST_NEW:
+ self.lukscb.set_data("formatstate", 1)
+ else:
+ self.lukscb.set_data("formatstate", 0)
+
+ if logrequest.encryption:
+ self.lukscb.set_active(1)
+ else:
+ self.lukscb.set_active(0)
+ maintable.attach(self.lukscb, 0, 2, row, row + 1)
+ row = row + 1
+ else:
+ self.lukscb = self.fsoptionsDict.get("lukscb")
+
dialog.vbox.pack_start(maintable)
dialog.show_all()
@@ -635,6 +653,20 @@ class VolumeGroupEditor:
# partRequest.py really.
request.dev = None
+ if self.lukscb and self.lukscb.get_active():
+ if request.encryption:
+ passphrase = request.encryption.passphrase
+ else:
+ passphrase = ""
+
+ passphrase = self.intf.getLuksPassphrase(passphrase)
+
+ if passphrase:
+ request.encryption = LUKSDevice(passphrase=passphrase,
+ format=1)
+ else:
+ request.encryption = None
+
# make list of original logvol requests so we can skip them
# in tests below. We check for mount point name conflicts
# above within the current volume group, so it is not
diff --git a/iw/task_gui.py b/iw/task_gui.py
index c323c6b83..e7a8e3a70 100644
--- a/iw/task_gui.py
+++ b/iw/task_gui.py
@@ -207,6 +207,11 @@ class RepoEditor:
if not self._enableRepo(repourl):
continue
+ # this is a bit gross... but we need to make sure that
+ # the urls and grabber get set back up based on new urls
+ self.repo._grab = None
+ self.repo._urls = None
+
if not setupRepo(self.anaconda, self.repo):
continue
diff --git a/kickstart.py b/kickstart.py
index f41b00f72..d990e9714 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -312,6 +312,9 @@ class LogVol(commands.logvol.F9_LogVol):
if lvd.fsopts != "":
request.fsopts = lvd.fsopts
+ if lvd.encrypted:
+ request.encryption = cryptodev.LUKSDevice(passphrase=lvd.passphrase, format=lvd.format)
+
addPartRequest(self.handler.anaconda, request)
self.handler.skipSteps.extend(["partition", "zfcpconfig", "parttype"])
diff --git a/livecd.py b/livecd.py
index f209558c5..922af8d28 100644
--- a/livecd.py
+++ b/livecd.py
@@ -339,26 +339,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend):
pass
def kernelVersionList(self, rootPath = "/"):
- versions = []
-
- # FIXME: we should understand more types of kernel versions and not
- # be tied to rpm...
- import rpm
- ts = rpm.TransactionSet(rootPath)
-
- # FIXME: and make sure that the rpmdb doesn't have stale locks :/
- for rpmfile in ["__db.000", "__db.001", "__db.002", "__db.003"]:
- try:
- os.unlink("%s/var/lib/rpm/%s" %(rootPath, rpmfile))
- except:
- log.debug("failed to unlink /var/lib/rpm/%s" %(rpmfile,))
-
- mi = ts.dbMatch('name', 'kernel')
- for h in mi:
- v = "%s-%s" %(h['version'], h['release'])
- versions.append( (v, h['arch'], "base") )
-
- return versions
+ return packages.rpmKernelVersionList(rootPath)
def doInitialSetup(self, anaconda):
pass
diff --git a/loader2/urls.c b/loader2/urls.c
index 9f8ebdc72..ce184e2fb 100644
--- a/loader2/urls.c
+++ b/loader2/urls.c
@@ -147,7 +147,7 @@ char *convertUIToURL(struct iurlinfo *ui) {
/* sanitize url so we dont have problems like bug #101265 */
/* basically avoid duplicate /'s */
if (ui->protocol == URL_METHOD_HTTP) {
- for (p=finalPrefix; *p == '/'; p++);
+ for (p=finalPrefix; *p == '/' && *(p+1) && *(p+1) == '/'; p++);
finalPrefix = p;
}
diff --git a/packages.py b/packages.py
index 36e268913..a6a8a1598 100644
--- a/packages.py
+++ b/packages.py
@@ -253,6 +253,49 @@ def setFileCons(anaconda):
return
+# FIXME: using rpm directly here is kind of lame, but in the yum backend
+# we don't want to use the metadata as the info we need would require
+# the filelists. and since we only ever call this after an install is
+# done, we can be guaranteed this will work. put here because it's also
+# used for livecd installs
+def rpmKernelVersionList(rootPath = "/"):
+ import rpm
+
+ def get_version(header):
+ for f in header['filenames']:
+ if f.startswith('/boot/vmlinuz-'):
+ return f[14:]
+ return ""
+
+ def get_tag(header):
+ if header['name'] == "kernel":
+ return "base"
+ elif header['name'].startswith("kernel-"):
+ return header['name'][7:]
+ return ""
+
+ versions = []
+
+ ts = rpm.TransactionSet(rootPath)
+
+ # FIXME: and make sure that the rpmdb doesn't have stale locks :/
+ for rpmfile in ["__db.000", "__db.001", "__db.002", "__db.003"]:
+ try:
+ os.unlink("%s/var/lib/rpm/%s" %(rootPath, rpmfile))
+ except:
+ log.debug("failed to unlink /var/lib/rpm/%s" %(rpmfile,))
+
+ mi = ts.dbMatch('provides', 'kernel')
+ for h in mi:
+ v = get_version(h)
+ tag = get_tag(h)
+ if v == "" or tag == "":
+ log.warning("Unable to determine kernel type/version for %s-%s-%s.%s" %(h['name'], h['version'], h['release'], h['arch']))
+ continue
+ versions.append( (v, h['arch'], tag) )
+
+ return versions
+
#Recreate initrd for use when driver disks add modules
def recreateInitrd (kernelTag, instRoot):
log.info("recreating initrd for %s" % (kernelTag,))
diff --git a/partRequests.py b/partRequests.py
index 750ef5ead..438ba4e29 100644
--- a/partRequests.py
+++ b/partRequests.py
@@ -952,14 +952,20 @@ class LogicalVolumeRequestSpec(RequestSpec):
else:
size = "%s percent" %(self.percent,)
+ if self.encryption is None:
+ crypto = "None"
+ else:
+ crypto = self.encryption.getScheme()
+
str = ("LV Request -- mountpoint: %(mount)s uniqueID: %(id)s\n"
" type: %(fstype)s format: %(format)s\n"
" size: %(size)s lvname: %(lvname)s volgroup: %(vgid)s\n"
- " options: '%(fsopts)s' fsprofile: %(fsprofile)s" %
+ " options: '%(fsopts)s' fsprofile: %(fsprofile)s"
+ " encryption: '%(crypto)s'" %
{"mount": self.mountpoint, "id": self.uniqueID,
"fstype": fsname, "format": self.format,
"lvname": self.logicalVolumeName, "vgid": self.volumeGroup,
- "size": size,
+ "size": size, "crypto": crypto,
"fsopts": self.fsopts, "fsprofile": self.fsprofile})
return str
@@ -970,7 +976,8 @@ class LogicalVolumeRequestSpec(RequestSpec):
self.dev = fsset.LogicalVolumeDevice(vgname, self.size,
self.logicalVolumeName,
vg = vg,
- existing = self.preexist)
+ existing = self.preexist,
+ encryption = self.encryption)
return self.dev
def isEncrypted(self, partitions, parentOnly = False):
diff --git a/scripts/mk-images b/scripts/mk-images
index cebb27921..88af4565b 100755
--- a/scripts/mk-images
+++ b/scripts/mk-images
@@ -780,9 +780,9 @@ for KERNELARCH in $arches; do
if [ "${kernelvers}" = "kernel-xen" ]; then kerneltag="xen" ; fi
- version=$(rpm --nodigest --nosignature --qf '%{VERSION}-%{RELEASE}' -qp $kpackage)${kerneltag}
+ vmlinuz=$(rpm --nodigest --nosignature -qpl $kpackage |grep ^/boot/vmlinuz | head -n 1)
+ version=${vmlinuz##/boot/vmlinuz-}
arch=$(rpm --nodigest --nosignature --qf '%{ARCH}\n' -qp $kpackage)
- echo "unpacking $kpackage"
rpm2cpio $kpackage | (cd $KERNELROOT; cpio --quiet -iumd)
rm -f $kpackage
diff --git a/yuminstall.py b/yuminstall.py
index cb6d5f877..be7318313 100644
--- a/yuminstall.py
+++ b/yuminstall.py
@@ -45,6 +45,7 @@ from product import productName, productStamp
from sortedtransaction import SplitMediaTransactionData
from constants import *
from image import *
+import packages
from rhpl.translate import _
# specspo stuff
@@ -1552,26 +1553,9 @@ class YumBackend(AnacondaBackend):
w.pop()
def kernelVersionList(self, rootPath="/"):
- kernelVersions = []
-
- # nick is used to generate the lilo name
- for (ktag, nick) in [ ('kernel-smp', 'smp'),
- ('kernel-xen0', 'xen0'),
- ('kernel-xenU', 'xenU'),
- ('kernel-xen', 'xen'),
- ('kernel-PAE', 'pae') ]:
- tag = ktag.rsplit('-', 1)[1]
- for tsmbr in filter(lambda p: p.output_state in TS_INSTALL_STATES,
- self.ayum.tsInfo.matchNaevr(name=ktag)):
- version = ( tsmbr.version + '-' + tsmbr.release + tag)
- kernelVersions.append((version, tsmbr.arch, nick))
-
- for tsmbr in filter(lambda p: p.output_state in TS_INSTALL_STATES,
- self.ayum.tsInfo.matchNaevr(name='kernel')):
- version = ( tsmbr.version + '-' + tsmbr.release)
- kernelVersions.append((version, tsmbr.arch, 'base'))
-
- return kernelVersions
+ # FIXME: using rpm here is a little lame, but otherwise, we'd
+ # be pulling in filelists
+ return packages.rpmKernelVersionList(rootPath)
def __getGroupId(self, group):
"""Get the groupid for the given name (english or translated)."""