summaryrefslogtreecommitdiffstats
path: root/textw
diff options
context:
space:
mode:
authorErik Troan <ewt@redhat.com>1999-09-09 13:33:58 +0000
committerErik Troan <ewt@redhat.com>1999-09-09 13:33:58 +0000
commit4a2d20b1a9f1a184df86542adead0adf81cfd408 (patch)
treec595bb1642fbecb33438fe7d57f402151bd515f5 /textw
parent83d3cda8d3e2e2404736dde1e413aa586e464b07 (diff)
downloadanaconda-4a2d20b1a9f1a184df86542adead0adf81cfd408.tar.gz
anaconda-4a2d20b1a9f1a184df86542adead0adf81cfd408.tar.xz
anaconda-4a2d20b1a9f1a184df86542adead0adf81cfd408.zip
initial split of huge text.py
Diffstat (limited to 'textw')
-rw-r--r--textw/Makefile7
-rw-r--r--textw/__init__.py0
-rw-r--r--textw/constants.py10
-rw-r--r--textw/lilo.py201
-rw-r--r--textw/packages.py150
-rw-r--r--textw/partitioning.py198
-rw-r--r--textw/userauth.py296
7 files changed, 862 insertions, 0 deletions
diff --git a/textw/Makefile b/textw/Makefile
new file mode 100644
index 000000000..55c8aecb7
--- /dev/null
+++ b/textw/Makefile
@@ -0,0 +1,7 @@
+all:
+ echo "nothing to make"
+
+install:
+ mkdir -p $(DESTDIR)/usr/lib/python1.5/site-packages/textw
+ cp -a *.py $(DESTDIR)/usr/lib/python1.5/site-packages/textw
+ ../py-compile --basedir $(DESTDIR)/usr/lib/python1.5/site-packages/textw $(DESTDIR)/usr/lib/python1.5/site-packages/textw/*.py
diff --git a/textw/__init__.py b/textw/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/textw/__init__.py
diff --git a/textw/constants.py b/textw/constants.py
new file mode 100644
index 000000000..2b7c1c94f
--- /dev/null
+++ b/textw/constants.py
@@ -0,0 +1,10 @@
+import gettext
+
+INSTALL_OK = 0
+INSTALL_BACK = -1
+INSTALL_NOOP = -2
+
+cat = gettext.Catalog ("anaconda", "/usr/share/locale")
+_ = cat.gettext
+
+basicButtons = ((_("Ok"), "ok"), (_("Back"), "back"))
diff --git a/textw/lilo.py b/textw/lilo.py
new file mode 100644
index 000000000..e8afcd4a4
--- /dev/null
+++ b/textw/lilo.py
@@ -0,0 +1,201 @@
+import gettext
+from snack import *
+from textw.constants import *
+
+cat = gettext.Catalog ("anaconda", "/usr/share/locale")
+_ = cat.gettext
+
+class LiloAppendWindow:
+
+ def __call__(self, screen, todo):
+ t = TextboxReflowed(53,
+ _("A few systems will need to pass special options "
+ "to the kernel at boot time for the system to function "
+ "properly. If you need to pass boot options to the "
+ "kernel, enter them now. If you don't need any or "
+ "aren't sure, leave this blank."))
+
+ cb = Checkbox(_("Use linear mode (needed for some SCSI drives)"))
+ entry = Entry(48, scroll = 1, returnExit = 1)
+ buttons = ButtonBar(screen, [(_("OK"), "ok"), (_("Skip"), "skip"),
+ (_("Back"), "back") ] )
+
+ grid = GridForm(screen, _("LILO Configuration"), 1, 4)
+ grid.add(t, 0, 0)
+ grid.add(cb, 0, 1, padding = (0, 1, 0, 1))
+ grid.add(entry, 0, 2, padding = (0, 0, 0, 1))
+ grid.add(buttons, 0, 3, growx = 1)
+
+ result = grid.runOnce ()
+ button = buttons.buttonPressed(result)
+
+ if button == "back":
+ return INSTALL_BACK
+
+ if button == "skip":
+ todo.skipLilo = 1
+ else:
+ todo.skipLilo = 0
+
+ return INSTALL_OK
+
+class LiloWindow:
+ def __call__(self, screen, todo):
+ if '/' not in todo.mounts.keys (): return INSTALL_NOOP
+ if todo.skipLilo: return INSTALL_NOOP
+
+ (bootpart, boothd) = todo.getLiloOptions()
+
+ if (todo.getLiloLocation == "mbr"):
+ default = boothd
+ elif (todo.getLiloLocation == "partition"):
+ default = bootpart
+ else:
+ default = 0
+
+ format = "/dev/%-11s %s"
+ locations = []
+ locations.append (format % (boothd, "Master Boot Record (MBR)"))
+ locations.append (format % (bootpart, "First sector of boot partition"))
+
+ (rc, sel) = ListboxChoiceWindow (screen, _("LILO Configuration"),
+ _("Where do you want to install the bootloader?"),
+ locations, default = default,
+ buttons = [ _("OK"), _("Back") ])
+
+ if sel == 0:
+ todo.setLiloLocation("mbr")
+ else:
+ todo.setLiloLocation("partition")
+
+ if rc == string.lower (_("Back")):
+ return INSTALL_BACK
+ return INSTALL_OK
+
+class LiloImagesWindow:
+ def editItem(self, screen, partition, itemLabel):
+ devLabel = Label(_("Device") + ":")
+ bootLabel = Label(_("Boot label") + ":")
+ device = Label("/dev/" + partition)
+ newLabel = Entry (20, scroll = 1, returnExit = 1, text = itemLabel)
+
+ buttons = ButtonBar(screen, [_("Ok"), _("Clear"), _("Cancel")])
+
+ subgrid = Grid(2, 2)
+ subgrid.setField(devLabel, 0, 0, anchorLeft = 1)
+ subgrid.setField(device, 1, 0, padding = (1, 0, 0, 0), anchorLeft = 1)
+ subgrid.setField(bootLabel, 0, 1, anchorLeft = 1)
+ subgrid.setField(newLabel, 1, 1, padding = (1, 0, 0, 0), anchorLeft = 1)
+
+ g = GridForm(screen, _("Edit Boot Label"), 1, 2)
+ g.add(subgrid, 0, 0, padding = (0, 0, 0, 1))
+ g.add(buttons, 0, 1, growx = 1)
+
+ result = ""
+ while (result != string.lower(_("Ok")) and result != newLabel):
+ result = g.run()
+ if (buttons.buttonPressed(result)):
+ result = buttons.buttonPressed(result)
+
+ if (result == string.lower(_("Cancel"))):
+ return itemLabel
+ elif (result == string.lower(_("Clear"))):
+ newLabel.set("")
+
+ screen.popWindow()
+
+ return newLabel.value()
+
+ def formatDevice(self, type, label, device, default):
+ if (type == 2):
+ type = "Linux extended"
+ elif (type == 1):
+ type = "DOS/Windows"
+ elif (type == 4):
+ type = "OS/2 / Windows NT"
+ else:
+ type = "Other"
+
+ if default == device:
+ default = '*'
+ else:
+ default = ""
+
+ return "%-10s %-25s %-7s %-10s" % ( "/dev/" + device, type, default, label)
+
+ def __call__(self, screen, todo):
+ images = todo.getLiloImages()
+ if not images: return INSTALL_NOOP
+ if todo.skipLilo: return INSTALL_NOOP
+
+ sortedKeys = images.keys()
+ sortedKeys.sort()
+
+ listboxLabel = Label("%-10s %-25s %-7s %-10s" %
+ ( _("Device"), _("Partition type"), _("Default"), _("Boot label")))
+ listbox = Listbox(5, scroll = 1, returnExit = 1)
+
+ default = ""
+
+ foundDos = 0
+ for n in sortedKeys:
+ (label, type) = images[n]
+ if (type == 1):
+ if (foundDos): continue
+ foundDos = 1
+ label = "dos"
+ images[n] = (label, type)
+ listbox.append(self.formatDevice(type, label, n, default), n)
+
+ buttons = ButtonBar(screen, [ (_("Ok"), "ok"), (_("Edit"), "edit"),
+ (_("Back"), "back") ] )
+
+ text = TextboxReflowed(55, _("The boot manager Red Hat uses can boot other "
+ "operating systems as well. You need to tell me "
+ "what partitions you would like to be able to boot "
+ "and what label you want to use for each of them."))
+
+ g = GridForm(screen, _("LILO Configuration"), 1, 4)
+ g.add(text, 0, 0, anchorLeft = 1)
+ g.add(listboxLabel, 0, 1, padding = (0, 1, 0, 0), anchorLeft = 1)
+ g.add(listbox, 0, 2, padding = (0, 0, 0, 1), anchorLeft = 1)
+ g.add(buttons, 0, 3, growx = 1)
+ g.addHotKey("F2")
+
+ result = None
+ while (result != "ok" and result != "back" and result != "F12"):
+ result = g.run()
+ if (buttons.buttonPressed(result)):
+ result = buttons.buttonPressed(result)
+
+ if (result == string.lower(_("Edit")) or result == listbox):
+ item = listbox.current()
+ (label, type) = images[item]
+ label = self.editItem(screen, item, label)
+ images[item] = (label, type)
+ if (default == item and not label):
+ default = ""
+ listbox.replace(self.formatDevice(type, label, item, default), item)
+ listbox.setCurrent(item)
+ elif result == "F2":
+ item = listbox.current()
+ (label, type) = images[item]
+ if (label):
+ if (default):
+ (oldLabel, oldType) = images[default]
+ listbox.replace(self.formatDevice(oldType, oldLabel, default,
+ ""), default)
+ default = item
+ listbox.replace(self.formatDevice(type, label, item, default),
+ item)
+ listbox.setCurrent(item)
+
+ screen.popWindow()
+
+ if (result == "back"):
+ return INSTALL_BACK
+
+ todo.setLiloImages(images)
+
+ return INSTALL_OK
+
diff --git a/textw/packages.py b/textw/packages.py
new file mode 100644
index 000000000..379239362
--- /dev/null
+++ b/textw/packages.py
@@ -0,0 +1,150 @@
+import rpm
+import gettext
+from snack import *
+from textw.constants import *
+
+cat = gettext.Catalog ("anaconda", "/usr/share/locale")
+_ = cat.gettext
+
+class PackageGroupWindow:
+ def __call__(self, screen, todo, individual):
+ # be sure that the headers and comps files have been read.
+ todo.getHeaderList()
+ todo.getCompsList()
+
+ ct = CheckboxTree(height = 10, scroll = 1)
+ for comp in todo.comps:
+ if not comp.hidden:
+ ct.append(comp.name, comp, comp.selected)
+
+ cb = Checkbox (_("Select individual packages"), individual.get ())
+
+ bb = ButtonBar (screen, ((_("OK"), "ok"), (_("Back"), "back")))
+
+ g = GridForm (screen, _("Package Group Selection"), 1, 3)
+ g.add (ct, 0, 0, (0, 0, 0, 1))
+ g.add (cb, 0, 1, (0, 0, 0, 1))
+ g.add (bb, 0, 2, growx = 1)
+
+ result = g.runOnce()
+
+ individual.set (cb.selected())
+ # turn off all the comps
+ for comp in todo.comps:
+ if not comp.hidden: comp.unselect(0)
+
+ # turn on all the comps we selected
+ for comp in ct.getSelection():
+ comp.select (1)
+
+ rc = bb.buttonPressed (result)
+
+ if rc == "back":
+ return INSTALL_BACK
+ return INSTALL_OK
+
+class IndividualPackageWindow:
+ def __call__(self, screen, todo, individual):
+ if not individual.get():
+ return
+ todo.getHeaderList()
+ todo.getCompsList()
+
+ ct = CheckboxTree(height = 10, scroll = 1)
+ groups = {}
+
+ # go through all the headers and grok out the group names, placing
+ # packages in lists in the groups dictionary.
+
+ for key in todo.hdList.packages.keys():
+ header = todo.hdList.packages[key]
+ # don't show this package if it is in the base group
+ if not todo.comps["Base"].items.has_key (header):
+ if not groups.has_key (header[rpm.RPMTAG_GROUP]):
+ groups[header[rpm.RPMTAG_GROUP]] = []
+ groups[header[rpm.RPMTAG_GROUP]].append (header)
+
+ # now insert the groups into the list, then each group's packages
+ # after sorting the list
+ def cmpHdrName(first, second):
+ if first[rpm.RPMTAG_NAME] < second[rpm.RPMTAG_NAME]:
+ return -1
+ elif first[rpm.RPMTAG_NAME] == second[rpm.RPMTAG_NAME]:
+ return 0
+ return 1
+
+ keys = groups.keys ()
+ keys.sort ()
+ index = 0
+ for key in keys:
+ groups[key].sort (cmpHdrName)
+ ct.append (key)
+ for header in groups[key]:
+ ct.addItem (header[rpm.RPMTAG_NAME], (index, snackArgs["append"]),
+ header, header.selected)
+ index = index + 1
+
+ bb = ButtonBar (screen, ((_("OK"), "ok"), (_("Back"), "back")))
+
+ g = GridForm (screen, _("Package Group Selection"), 1, 2)
+ g.add (ct, 0, 0, (0, 0, 0, 1))
+ g.add (bb, 0, 1, growx = 1)
+
+ result = g.runOnce ()
+
+ # turn off all the packages
+ for key in todo.hdList.packages.keys ():
+ todo.hdList.packages[key].selected = 0
+
+ # turn on all the packages we selected
+ for package in ct.getSelection ():
+ package.selected = 1
+
+ rc = bb.buttonPressed (result)
+
+ if rc == "back":
+ return INSTALL_BACK
+
+ return INSTALL_OK
+
+class PackageDepWindow:
+ def __call__(self, screen, todo):
+ deps = todo.verifyDeps ()
+ if not deps:
+ return INSTALL_NOOP
+
+ g = GridForm(screen, _("Package Dependencies"), 1, 5)
+ g.add (TextboxReflowed (45, _("Some of the packages you have "
+ "selected to install require "
+ "packages you have not selected. If "
+ "you just select Ok all of those "
+ "required packages will be "
+ "installed.")), 0, 0, (0, 0, 0, 1))
+ g.add (Label ("%-20s %-20s" % (_("Package"), _("Requirement"))), 0, 1, anchorLeft = 1)
+ text = ""
+ for name, suggest in deps:
+ text = text + "%-20s %-20s\n" % (name, suggest)
+
+ if len (deps) > 5:
+ scroll = 1
+ else:
+ scroll = 0
+
+ g.add (Textbox (45, 5, text, scroll = scroll), 0, 2, anchorLeft = 1)
+
+ cb = Checkbox (_("Install packages to satisfy dependencies"), 1)
+ g.add (cb, 0, 3, (0, 1, 0, 1), growx = 1)
+
+ bb = ButtonBar (screen, ((_("OK"), "ok"), (_("Back"), "back")))
+ g.add (bb, 0, 4, growx = 1)
+
+ result = g.runOnce ()
+
+ if cb.selected ():
+ todo.selectDeps (deps)
+
+ rc = bb.buttonPressed (result)
+ if rc == string.lower (_("Back")):
+ return INSTALL_BACK
+ return INSTALL_OK
+
diff --git a/textw/partitioning.py b/textw/partitioning.py
new file mode 100644
index 000000000..b1671fc53
--- /dev/null
+++ b/textw/partitioning.py
@@ -0,0 +1,198 @@
+import gettext
+import iutil
+import os
+from snack import *
+from textw.constants import *
+from newtpyfsedit import fsedit
+
+cat = gettext.Catalog ("anaconda", "/usr/share/locale")
+_ = cat.gettext
+
+class PartitionMethod:
+ def __call__(self, screen, todo):
+ if not todo.expert or todo.instClass.partitions:
+ todo.skipFdisk = 1
+ return INSTALL_NOOP
+
+ rc = ButtonChoiceWindow(screen, _("Disk Setup"),
+ _("Disk Druid is a tool for partitioning and setting up mount "
+ "points. It is designed to be easier to use than Linux's "
+ "traditional disk partitioning sofware, fdisk, as well "
+ "as more powerful. However, there are some cases where fdisk "
+ "may be preferred.\n"
+ "\n"
+ "Which tool would you like to use?"),
+ [ (_("Disk Druid"), "dd") , (_("fdisk"), "fd"),
+ (_("Back"), "back") ], width = 50)
+
+ if rc == "back":
+ return INSTALL_BACK
+ elif rc == "dd":
+ todo.skipFdisk = 1
+ else:
+ todo.skipFdisk = 0
+
+ return INSTALL_OK
+
+class ManualPartitionWindow:
+ def __call__(self, screen, todo):
+ if todo.skipFdisk: return INSTALL_NOOP
+
+ drives = todo.drives.available ()
+ driveNames = drives.keys()
+ driveNames.sort ()
+
+ choices = []
+ for device in driveNames:
+ descrip = drives[device]
+ if descrip:
+ choices.append("/dev/%s - %s" % (device, descrip))
+ else:
+ choices.append("/dev/%s" % (device,))
+
+ button = None
+ while button != "done" and button != "back":
+ (button, choice) = \
+ ListboxChoiceWindow(screen, _("Disk Setup"),
+ _("To install Red Hat Linux, you must have at least one "
+ "partition of 150 MB dedicated to Linux. We suggest "
+ "placing that partition on one of the first two hard "
+ "drives in your system so you can boot into Linux "
+ "with LILO."), choices,
+ [ (_("Done"), "done") , (_("Edit"), "edit"),
+ (_("Back"), "back") ], width = 50)
+
+ if button != "done" and button != "back":
+ device = driveNames[choice]
+ screen.suspend ()
+ if os.access("/sbin/fdisk", os.X_OK):
+ path = "/sbin/fdisk"
+ else:
+ path = "/usr/sbin/fdisk"
+ iutil.execWithRedirect (path, [ "/dev/" + device ])
+ screen.resume ()
+
+ if button == "back":
+ return INSTALL_BACK
+
+ return INSTALL_OK
+
+
+class AutoPartitionWindow:
+ def __call__(self, screen, todo):
+ fstab = []
+ for mntpoint, (dev, fstype, reformat) in todo.mounts.items ():
+ fstab.append ((dev, mntpoint))
+
+ if not todo.ddruid:
+ drives = todo.drives.available ().keys ()
+ drives.sort ()
+ todo.ddruid = fsedit(0, drives, fstab, todo.zeroMbr)
+
+ todo.instClass.finishPartitioning(todo.ddruid)
+
+ if not todo.getPartitionWarningText():
+ return INSTALL_NOOP
+
+ (rc, choice) = ListboxChoiceWindow(screen, _("Automatic Partitioning"),
+ _("%s\n\nIf you don't want to do this, you can continue with "
+ "this install by partitioning manually, or you can go back "
+ "and perform a fully customized installation.") %
+ (todo.getPartitionWarningText(), ),
+ [_("Continue"), _("Manually partition")],
+ buttons = basicButtons, default = _("Continue"))
+
+ if (rc == "back"): return INSTALL_BACK
+
+ if (choice == 1):
+ todo.ddruid = fsedit(0, drives, fstab)
+ todo.manuallyPartition()
+
+class PartitionWindow:
+ def __call__(self, screen, todo):
+ dir = INSTALL_NOOP
+ if not todo.getSkipPartitioning():
+ dir = todo.ddruid.edit ()
+
+ for partition, mount, fstype, size in todo.ddruid.getFstab ():
+ todo.addMount(partition, mount, fstype)
+
+ return dir
+
+class TurnOnSwapWindow:
+
+ beenTurnedOn = 0
+
+ def __call__(self, screen, todo):
+ if self.beenTurnedOn or (iutil.memInstalled() > 30000):
+ return INSTALL_NOOP
+
+ rc = ButtonChoiceWindow(screen, _("Low Memory"),
+ _("As you don't have much memory in this machine, we "
+ "need to turn on swap space immediately. To do this "
+ "we'll have to write your new partition table to the "
+ "disk immediately. Is that okay?"),
+ [ (_("Yes"), "yes"), (_("No"), "back") ], width = 50)
+
+ if (rc == "back"):
+ return INSTALL_BACK
+
+ todo.ddruid.save ()
+ todo.makeFilesystems (createFs = 0)
+ todo.ddruidAlreadySaved = 1
+ self.beenTurnedOn = 1
+
+ return INSTALL_OK
+
+class FormatWindow:
+ def __call__(self, screen, todo):
+ tb = TextboxReflowed (55,
+ _("What partitions would you like to "
+ "format? We strongly suggest formatting "
+ "all of the system partitions, including "
+ "/, /usr, and /var. There is no need to "
+ "format /home or /usr/local if they have "
+ "already been configured during a "
+ "previous install."))
+
+ height = min (screen.height - 12, len (todo.mounts.items()))
+
+ ct = CheckboxTree(height = height)
+
+ mounts = todo.mounts.keys ()
+ mounts.sort ()
+
+ for mount in mounts:
+ (dev, fstype, format) = todo.mounts[mount]
+ if fstype == "ext2":
+ ct.append("/dev/%s %s" % (dev, mount), mount, format)
+
+ cb = Checkbox (_("Check for bad blocks during format"))
+
+ bb = ButtonBar (screen, ((_("OK"), "ok"), (_("Back"), "back")))
+
+ g = GridForm (screen, _("Choose Partitions to Format"), 1, 4)
+ g.add (tb, 0, 0, (0, 0, 0, 1))
+ g.add (ct, 0, 1)
+ g.add (cb, 0, 2, (0, 0, 0, 1))
+ g.add (bb, 0, 3, growx = 1)
+
+ result = g.runOnce()
+
+ for mount in todo.mounts.keys ():
+ (dev, fstype, format) = todo.mounts[mount]
+ if fstype == "ext2":
+ todo.mounts[mount] = (dev, fstype, 0)
+
+ for mount in ct.getSelection():
+ (dev, fstype, format) = todo.mounts[mount]
+ todo.mounts[mount] = (dev, fstype, 1)
+
+ todo.badBlockCheck = cb.selected ()
+
+ rc = bb.buttonPressed (result)
+
+ if rc == "back":
+ return INSTALL_BACK
+ return INSTALL_OK
+
diff --git a/textw/userauth.py b/textw/userauth.py
new file mode 100644
index 000000000..b4c55126a
--- /dev/null
+++ b/textw/userauth.py
@@ -0,0 +1,296 @@
+import gettext
+from snack import *
+from textw.constants import *
+
+cat = gettext.Catalog ("anaconda", "/usr/share/locale")
+_ = cat.gettext
+
+class RootPasswordWindow:
+ def __call__ (self, screen, todo):
+ toplevel = GridForm (screen, _("Root Password"), 1, 3)
+
+ toplevel.add (TextboxReflowed(37, _("Pick a root password. You must "
+ "type it twice to ensure you know "
+ "what it is and didn't make a mistake "
+ "in typing. Remember that the "
+ "root password is a critical part "
+ "of system security!")), 0, 0, (0, 0, 0, 1))
+
+ pw = todo.rootpassword.getPure()
+ if not pw: pw = ""
+
+ entry1 = Entry (24, hidden = 1, text = pw)
+ entry2 = Entry (24, hidden = 1, text = pw)
+ passgrid = Grid (2, 2)
+ passgrid.setField (Label (_("Password:")), 0, 0, (0, 0, 1, 0), anchorLeft = 1)
+ passgrid.setField (Label (_("Password (again):")), 0, 1, (0, 0, 1, 0), anchorLeft = 1)
+ passgrid.setField (entry1, 1, 0)
+ passgrid.setField (entry2, 1, 1)
+ toplevel.add (passgrid, 0, 1, (0, 0, 0, 1))
+
+ bb = ButtonBar (screen, ((_("OK"), "ok"), (_("Back"), "back")))
+ toplevel.add (bb, 0, 2, growx = 1)
+
+ while 1:
+ toplevel.setCurrent (entry1)
+ result = toplevel.run ()
+ rc = bb.buttonPressed (result)
+ if rc == "back":
+ screen.popWindow()
+ return INSTALL_BACK
+ if len (entry1.value ()) < 6:
+ ButtonChoiceWindow(screen, _("Password Length"),
+ _("The root password must be at least 6 characters "
+ "long."),
+ buttons = [ _("OK") ], width = 50)
+ elif entry1.value () != entry2.value ():
+ ButtonChoiceWindow(screen, _("Password Mismatch"),
+ _("The passwords you entered were different. Please "
+ "try again."),
+ buttons = [ _("OK") ], width = 50)
+ else:
+ break
+
+ entry1.set ("")
+ entry2.set ("")
+
+ screen.popWindow()
+ todo.rootpassword.set (entry1.value ())
+ return INSTALL_OK
+
+class UsersWindow:
+ def editWindow (self, user, text, edit = 0, cancelText = None):
+ if (not cancelText):
+ cancelText = _("Cancel")
+
+ userid = Entry (8, user["id"])
+ currentid = user["id"]
+ fullname = Entry (20, user["name"], scroll = 1)
+ pass1 = Entry (10, user["password"], hidden = 1)
+ pass2 = Entry (10, user["password"], hidden = 1)
+
+ if edit:
+ title = _("Edit User")
+ else:
+ title = _("Add User")
+
+ while 1:
+
+ (rc, ent) = EntryWindow (self.screen, title, text,
+ [ (_("User ID"), userid),
+ (_("Full Name"), fullname),
+ (_("Password"), pass1),
+ (_("Password (confirm)"), pass2) ],
+ buttons = [ (_("OK"), "ok"), (cancelText, "cancel") ])
+
+ if rc == "cancel":
+ return INSTALL_BACK
+ if not len(pass1.value()) and not len(pass2.value()) and \
+ not len(userid.value()) and not len(fullname.value()):
+ return INSTALL_OK
+
+ if len (pass1.value ()) < 6:
+ ButtonChoiceWindow(self.screen, _("Password Length"),
+ _("The password must be at least 6 characters "
+ "long."),
+ buttons = [ _("OK") ], width = 50)
+ pass1.set ("")
+ pass2.set ("")
+ continue
+ elif pass1.value () != pass2.value ():
+ ButtonChoiceWindow(self.screen, _("Password Mismatch"),
+ _("The passwords you entered were different. Please "
+ "try again."),
+ buttons = [ _("OK") ], width = 50)
+ pass1.set ("")
+ pass2.set ("")
+ continue
+
+ if self.users.has_key (userid.value ()) and \
+ userid.value () != currentid:
+ ButtonChoiceWindow(self.screen, _("User Exists"),
+ _("This user id already exists. Choose another."),
+ buttons = [ _("OK") ], width = 50)
+ continue
+
+ # XXX FIXME - more data validity checks
+
+ user["id"] = userid.value ()
+ user["name"] = fullname.value ()
+ user["password"] = pass1.value ()
+ break
+
+ return INSTALL_OK
+
+ def __call__ (self, screen, todo):
+ self.users = {}
+ self.screen = screen
+ user = { "id" : "", "name" : "", "password" : "" }
+
+ for (account, name, password) in todo.getUserList():
+ user['id'] = account
+ user['name'] = name
+ user['password'] = password
+ self.users[account] = user
+ del user
+ user = { "id" : "", "name" : "", "password" : "" }
+
+ if not self.users.keys():
+ rc = self.editWindow(user, _("You should use a normal user "
+ "account for most activities on your system. By not using the "
+ "root account casually, you'll reduce the chance of "
+ "disrupting your system's configuration."),
+ cancelText = _("Back"))
+ if (rc == INSTALL_BACK):
+ return INSTALL_BACK
+ if (not user['id']):
+ return INSTALL_OK
+ self.users[user["id"]] = user
+
+ g = GridForm (screen, _("User Account Setup"), 1, 4)
+
+ t = TextboxReflowed(60, _("What user account would you like to have "
+ "on the system? You should have at least one non-root account "
+ "for normal work, but multi-user systems can have any number "
+ "of accounts set up."))
+ g.add(t, 0, 0, anchorLeft = 1, padding = (0, 0, 0, 1))
+
+ listformat = "%-15s %-40s"
+ userformat = "%(id)-15s %(name)-40s"
+
+ subgrid = Grid(1, 2)
+ header = listformat % (_("User name"), _("Full Name"))
+ label = Label (header)
+ subgrid.setField (label, 0, 0, anchorLeft = 1)
+ listbox = Listbox (5, scroll = 1, returnExit = 1, width = 54)
+ subgrid.setField (listbox, 0, 1, (0, 0, 0, 1), anchorLeft = 1)
+
+ g.add(subgrid, 0, 1)
+
+ for user in self.users.values ():
+ listbox.append (userformat % user, user["id"])
+
+ bb = ButtonBar (screen, ((_("Add"), "add"), (_("Delete"), "delete"),
+ (_("Edit"), "edit"), (_("OK"), "ok"), (_("Back"), "back")))
+
+ g.add (bb, 0, 3, growx = 1)
+
+ while 1:
+ result = g.run ()
+
+ rc = bb.buttonPressed (result)
+
+ if rc == "add":
+ user = { "id" : "", "name" : "", "password" : "" }
+ self.editWindow (user,
+ _("Enter the information for the user."), 0)
+ listbox.append (userformat % user, user["id"])
+ listbox.setCurrent (user["id"])
+ self.users[user["id"]] = user
+ elif rc == "delete":
+ current = listbox.current ()
+ listbox.delete (current)
+ del self.users [current]
+ elif rc == "edit" or result == listbox:
+ current = listbox.current()
+ user = self.users[current]
+ self.editWindow (user,
+ _("Change the information for this user."), 1)
+ # if the user id changed, we need to delete the old key
+ # and insert this new one.
+ if user["id"] != current:
+ del self.users [current]
+ listbox.insert (userformat % user, user["id"], current)
+ listbox.delete (current)
+ # and if the user id didn't change, just replace the old
+ # listbox entry.
+ else:
+ listbox.replace (userformat % user, user["id"])
+ self.users [user["id"]] = user
+ listbox.setCurrent(user["id"])
+ elif rc == "ok" or result == "F12":
+ dir = INSTALL_OK
+ break
+ elif rc == "back":
+ dir = INSTALL_BACK
+ break
+ else:
+ raise NeverGetHereError, "I shouldn't be here w/ rc %s..." % rc
+
+ screen.popWindow ()
+
+ list = []
+ for n in self.users.values():
+ info = ( n['id'], n['name'], n['password'] )
+ list.append(info)
+
+ todo.setUserList(list)
+
+ return dir
+
+class AuthConfigWindow:
+ def __call__(self, screen, todo):
+ def setsensitive (self):
+ server = FLAGS_RESET
+ flag = FLAGS_RESET
+ if self.broadcast.selected ():
+ server = FLAGS_SET
+ if not self.nis.selected ():
+ flag = FLAGS_SET
+ server = FLAGS_SET
+
+ self.domain.setFlags (FLAG_DISABLED, flag)
+ self.broadcast.setFlags (FLAG_DISABLED, flag)
+ self.server.setFlags (FLAG_DISABLED, server)
+
+ bb = ButtonBar (screen, ((_("OK"), "ok"), (_("Back"), "back")))
+
+ toplevel = GridForm (screen, _("Authentication Configuration"), 1, 5)
+ self.shadow = Checkbox (_("Use Shadow Passwords"), todo.auth.useShadow)
+ toplevel.add (self.shadow, 0, 0, (0, 0, 0, 1), anchorLeft = 1)
+ self.md5 = Checkbox (_("Enable MD5 Passwords"), todo.auth.useMD5)
+ toplevel.add (self.md5, 0, 1, (0, 0, 0, 1), anchorLeft = 1)
+ self.nis = Checkbox (_("Enable NIS"), todo.auth.useNIS)
+ toplevel.add (self.nis, 0, 2, anchorLeft = 1)
+
+ subgrid = Grid (2, 3)
+
+ subgrid.setField (Label (_("NIS Domain:")),
+ 0, 0, (0, 0, 1, 0), anchorRight = 1)
+ subgrid.setField (Label (_("NIS Server:")),
+ 0, 1, (0, 0, 1, 0), anchorRight = 1)
+ subgrid.setField (Label (_("or use:")),
+ 0, 2, (0, 0, 1, 0), anchorRight = 1)
+
+ text = _("Request server via broadcast")
+ self.domain = Entry (len (text) + 4)
+ self.domain.set (todo.auth.domain)
+ self.broadcast = Checkbox (text, todo.auth.useBroadcast)
+ self.server = Entry (len (text) + 4)
+ self.server.set (todo.auth.server)
+ subgrid.setField (self.domain, 1, 0, anchorLeft = 1)
+ subgrid.setField (self.broadcast, 1, 1, anchorLeft = 1)
+ subgrid.setField (self.server, 1, 2, anchorLeft = 1)
+ toplevel.add (subgrid, 0, 3, (2, 0, 0, 1))
+ toplevel.add (bb, 0, 4, growx = 1)
+
+ self.nis.setCallback (setsensitive, self)
+ self.broadcast.setCallback (setsensitive, self)
+
+ setsensitive (self)
+
+ result = toplevel.runOnce ()
+
+ todo.auth.useMD5 = self.md5.value ()
+ todo.auth.shadow = self.shadow.value ()
+ todo.auth.useNIS = self.nis.selected ()
+ todo.auth.domain = self.domain.value ()
+ todo.auth.useBroadcast = self.broadcast.selected ()
+ todo.auth.server = self.server.value ()
+
+ rc = bb.buttonPressed (result)
+
+ if rc == "back":
+ return INSTALL_BACK
+ return INSTALL_OK
+