summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2001-07-10 19:34:13 +0000
committerJeremy Katz <katzj@redhat.com>2001-07-10 19:34:13 +0000
commit9b92c8b12de64ef6de42298c9da3c296681f80f1 (patch)
tree03d1c7079c4dcf02c39b24906602bd0f7a55809e
parent88e2f64d73445cafa2eb3917b69e9cccc0f5ccfc (diff)
downloadanaconda-9b92c8b12de64ef6de42298c9da3c296681f80f1.tar.gz
anaconda-9b92c8b12de64ef6de42298c9da3c296681f80f1.tar.xz
anaconda-9b92c8b12de64ef6de42298c9da3c296681f80f1.zip
add ability to set grub password in gui and tui
-rw-r--r--bootloader.py7
-rw-r--r--iw/bootloader_gui.py100
-rw-r--r--text.py3
-rw-r--r--textw/bootloader_text.py77
4 files changed, 184 insertions, 3 deletions
diff --git a/bootloader.py b/bootloader.py
index e24d98a36..66109da54 100644
--- a/bootloader.py
+++ b/bootloader.py
@@ -334,6 +334,11 @@ class ia64BootloaderInfo(bootloaderInfo):
class x86BootloaderInfo(bootloaderInfo):
def setPassword(self, val, isCrypted = 1):
+ if not val:
+ self.password = val
+ self.pure = val
+ return
+
if isCrypted:
self.password = val
else:
@@ -345,6 +350,7 @@ class x86BootloaderInfo(bootloaderInfo):
string.digits + './')
self.password = crypt.crypt (val, salt)
+ self.pure = val
def setForceLBA(self, val):
self.forceLBA32 = val
@@ -509,6 +515,7 @@ class x86BootloaderInfo(bootloaderInfo):
self.kernelLocation = "/boot/"
self.configfile = "/etc/lilo.conf"
self.password = None
+ self.pure = None
def availableBootDevices(diskSet, fsset):
devs = []
diff --git a/iw/bootloader_gui.py b/iw/bootloader_gui.py
index ec958012b..a65024dc1 100644
--- a/iw/bootloader_gui.py
+++ b/iw/bootloader_gui.py
@@ -2,6 +2,7 @@
from iw_gui import *
from gtk import *
+from gnome.ui import *
from translate import _, N_
from xpms_gui import CHECKBOX_ON_XPM
from xpms_gui import CHECKBOX_OFF_XPM
@@ -78,6 +79,11 @@ class BootloaderWindow (InstallWindow):
if not default:
default = linuxDevice
+ if self.usegrubpasscb.get_active():
+ self.bl.setPassword(self.password, isCrypted = 0)
+ else:
+ self.bl.setPassword(None)
+
self.bl.images.setDefault(default)
@@ -136,7 +142,8 @@ class BootloaderWindow (InstallWindow):
list = self.bootDevice.keys()
list.extend ([self.appendEntry, self.editBox, self.imageList,
- self.liloLocationBox, self.radioBox, self.sw])
+ self.liloLocationBox, self.radioBox, self.sw,
+ self.passtable])
for n in list:
n.set_sensitive (state)
@@ -236,8 +243,10 @@ class BootloaderWindow (InstallWindow):
def bootloaderchange(self, widget):
if self.lilo_radio.get_active():
selected = "lilo"
+ self.passtable.set_sensitive(FALSE)
elif self.grub_radio.get_active():
selected = "grub"
+ self.passtable.set_sensitive(TRUE)
elif self.none_radio.get_active():
return
@@ -253,10 +262,68 @@ class BootloaderWindow (InstallWindow):
self.imageList.set_text(index, 3, tmp)
self.labelSelected()
+ def usePasswordToggle(self, *args):
+ if self.usegrubpasscb.get_active():
+ self.passbutton.set_sensitive(TRUE)
+ if not self.bl.password and not self.password:
+ self.ics.setNextEnabled(0)
+ else:
+ self.passbutton.set_sensitive(FALSE)
+
+ def passwordDialog(self, *args):
+ dialog = GnomeDialog(_("GRUB Password"))
+ dialog.append_button (_("OK"))
+ dialog.append_button (_("Cancel"))
+ dialog.set_position(WIN_POS_CENTER)
+ dialog.close_hides(TRUE)
+
+ maintable = GtkTable()
+ maintable.set_row_spacings (5)
+ maintable.set_col_spacings (5)
+ pass1 = GtkLabel (_("Bootloader Password: "))
+ pass1.set_alignment (0.0, 0.5)
+ maintable.attach (pass1, 0, 1, 1, 2, FILL, 0, 10)
+ pass2 = GtkLabel (_("Confirm: "))
+ pass2.set_alignment (0.0, 0.5)
+ maintable.attach (pass2, 0, 1, 2, 3, FILL, 0, 10)
+ self.pw = GtkEntry (16)
+ self.pw.set_visibility (FALSE)
+ self.confirm = GtkEntry (16)
+ self.confirm.set_visibility (FALSE)
+ if self.password:
+ self.pw.set_text(self.password)
+ self.confirm.set_text(self.password)
+ maintable.attach (self.pw, 1, 2, 1, 2, 0, 5)
+ maintable.attach (self.confirm, 1, 2, 2, 3, 0, 5)
+ dialog.vbox.pack_start(maintable)
+ dialog.show_all()
+
+ while 1:
+ rc = dialog.run()
+
+ # user hit cancel, do nothing
+ if rc == 1:
+ dialog.close()
+ return
+
+ pw = self.pw.get_text()
+ confirm = self.confirm.get_text()
+
+ if pw != confirm:
+ self.intf.messageWindow(_("Passwords Do Not Match"),
+ _("Passwords do not match"))
+ continue
+
+ self.password = pw
+ self.ics.setNextEnabled(1)
+ dialog.close()
+ break
+
# LiloWindow tag="lilo"
def getScreen(self, dispatch, bl, fsset, diskSet):
self.dispatch = dispatch
self.bl = bl
+ self.intf = dispatch.intf
self.rootdev = fsset.getEntryByMountPoint("/").device.getDevice()
@@ -352,9 +419,38 @@ class BootloaderWindow (InstallWindow):
box.pack_start(self.radio_vbox, FALSE)
+ self.passtable = GtkTable (3, 3)
+ self.passtable.set_row_spacings (5)
+ self.passtable.set_col_spacings (5)
+ grubpassinfo = GtkLabel(_("A GRUB password prevents users from passing arbitrary options to the kernel. For highest security, we recommend setting a password, but this is not necessary for more casual users."))
+ self.password = None
+ grubpassinfo.set_line_wrap(TRUE)
+ grubpassinfo.set_usize(400, -1)
+ grubpassinfo.set_alignment(0.0,0.0)
+ self.passtable.attach(grubpassinfo, 0, 3, 0, 1, FILL|EXPAND, 0, 10)
+
+ self.usegrubpasscb = GtkCheckButton(_("Use a GRUB Password?"))
+ self.passtable.attach(self.usegrubpasscb, 0, 1, 1, 2, FILL, 0, 10)
+ self.passbutton = GtkButton(_("Set Password"))
+ self.passtable.attach(self.passbutton, 1, 2, 1, 2, 0, 0, 10)
+
+ self.usegrubpasscb.connect("toggled", self.usePasswordToggle)
+ self.passbutton.connect("clicked", self.passwordDialog)
+ if self.bl.password:
+ self.usegrubpasscb.set_active(1)
+ if self.bl.pure:
+ self.password = self.bl.pure
+ self.usePasswordToggle()
+
+ bogus = GtkLabel("")
+ self.passtable.attach(bogus, 2, 3, 1, 2, FILL|EXPAND, 0, 10)
+
box.pack_start (GtkHSeparator (), FALSE)
- box.pack_start (self.radioBox, FALSE)
+ box.pack_start(self.passtable, FALSE)
+ box.pack_start (GtkHSeparator (), FALSE)
+ box.pack_start (self.radioBox, FALSE)
+
sortedKeys = imageList.keys()
sortedKeys.sort()
self.numImages = len(sortedKeys)
diff --git a/text.py b/text.py
index 1336831cc..6e10c6682 100644
--- a/text.py
+++ b/text.py
@@ -47,8 +47,9 @@ stepToClasses = {
"CustomizeUpgradeWindow")),
"addswap" : ("upgrade_text", "UpgradeSwapWindow"),
"bootloader" : ("bootloader_text", ("BootloaderChoiceWindow",
- "BootloaderAppendWindow",
+ "bootloaderPassword",
"BootloaderWindow",
+ "BootloaderAppendWindow",
"BootloaderImagesWindow")),
"network" : ("network_text", ("NetworkWindow", "HostnameWindow")),
"firewall" : ("firewall_text", "FirewallWindow"),
diff --git a/textw/bootloader_text.py b/textw/bootloader_text.py
index dcda0702d..72d836b73 100644
--- a/textw/bootloader_text.py
+++ b/textw/bootloader_text.py
@@ -307,3 +307,80 @@ class BootloaderImagesWindow:
return INSTALL_OK
+class bootloaderPassword:
+ def usepasscb(self, *args):
+ flag = FLAGS_RESET
+ if not self.checkbox.selected():
+ flag = FLAGS_SET
+ self.entry1.setFlags(FLAG_DISABLED, flag)
+ self.entry2.setFlags(FLAG_DISABLED, flag)
+
+ def __call__(self, screen, dispatch, bl, fsset, diskSet):
+ if not bl.useGrub:
+ return
+
+ self.bl = bl
+
+ buttons = ButtonBar(screen, [TEXT_OK_BUTTON, TEXT_BACK_BUTTON])
+
+ text = TextboxReflowed(55,
+ _("A GRUB password prevents users from passing arbitrary"
+ "options to the kernel. For highest security, we"
+ "recommend setting a password, but this is not"
+ "necessary for more casual users."))
+
+ g = GridFormHelp(screen, _("Boot Loader Configuration"),
+ "grubpass", 1, 6)
+ g.add(text, 0, 0, (0,0,0,1), anchorLeft = 1)
+
+
+ self.checkbox = Checkbox(_("Use a GRUB Password"))
+ g.add(self.checkbox, 0, 1, (0,0,0,1))
+
+ if self.bl.password:
+ self.checkbox.setValue("*")
+
+ pw = self.bl.pure
+ if not pw: pw = ""
+
+ self.entry1 = Entry (24, password = 1, text = pw)
+ self.entry2 = Entry (24, password = 1, text = pw)
+ passgrid = Grid (2, 2)
+ passgrid.setField (Label (_("Boot Loader Password:")), 0, 0, (0, 0, 1, 0), anchorLeft = 1)
+ passgrid.setField (Label (_("Confirm:")), 0, 1, (0, 0, 1, 0), anchorLeft = 1)
+ passgrid.setField (self.entry1, 1, 0)
+ passgrid.setField (self.entry2, 1, 1)
+ g.add (passgrid, 0, 2, (0, 0, 0, 1))
+
+ self.checkbox.setCallback(self.usepasscb, None)
+ self.usepasscb()
+
+ g.add(buttons, 0, 3, growx=1)
+
+ while 1:
+ result = g.run()
+
+ if (buttons.buttonPressed(result)):
+ result = buttons.buttonPressed(result)
+
+ if (result == "cancel"):
+ screen.popWindow()
+ return INSTALL_BACK
+
+ if not self.checkbox.selected():
+ bl.setPassword(None)
+ screen.popWindow()
+ return INSTALL_OK
+
+ pw = self.entry1.value()
+ confirm = self.entry2.value()
+
+ if pw != confirm:
+ dispatch.intf.messageWindow(_("Passwords Do Not Match"),
+ _("Passwords do not match"))
+ continue
+
+ bl.setPassword(pw, isCrypted = 0)
+
+ screen.popWindow()
+ return INSTALL_OK