]> git.ipfire.org Git - ipfire-3.x.git/blob - src/pomona/tui_userauth.py
Added quiet option to kernel command line of the final system.
[ipfire-3.x.git] / src / pomona / tui_userauth.py
1 #
2 # userauth_text.py: text mode authentication setup dialogs
3 #
4 # Copyright 2000-2002 Red Hat, Inc.
5 #
6 # This software may be freely redistributed under the terms of the GNU
7 # library public license.
8 #
9 # You should have received a copy of the GNU Library Public License
10 # along with this program; if not, write to the Free Software
11 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
12 #
13
14 from snack import *
15 from constants import *
16
17 import gettext
18 _ = lambda x: gettext.ldgettext("pomona", x)
19
20 def has_bad_chars(pw):
21 allowed = string.digits + string.ascii_letters + string.punctuation + " "
22 for letter in pw:
23 if letter not in allowed:
24 return 1
25 return 0
26
27 class RootPasswordWindow:
28 def __call__ (self, screen, pomona):
29 toplevel = GridFormHelp(screen, _("Root Password"), "rootpw", 1, 3)
30
31 toplevel.add(TextboxReflowed(37, _("Pick a root password. You must "
32 "type it twice to ensure you know "
33 "it and do not make a typing mistake. "
34 "Remember that the root password is"
35 "a critical part of system "
36 "security!")), 0, 0, (0, 0, 0, 1))
37
38 entry1 = Entry(24, password = 1, text = pomona.id.rootPassword["password"])
39 entry2 = Entry(24, password = 1, text = pomona.id.rootPassword["password"])
40 passgrid = Grid(2, 2)
41 passgrid.setField(Label(_("Password:")), 0, 0, (0, 0, 1, 0), anchorLeft = 1)
42 passgrid.setField(Label(_("Password (confirm):")), 0, 1, (0, 0, 1, 0), anchorLeft = 1)
43 passgrid.setField(entry1, 1, 0)
44 passgrid.setField(entry2, 1, 1)
45 toplevel.add(passgrid, 0, 1, (0, 0, 0, 1))
46
47 bb = ButtonBar(screen, (TEXT_OK_BUTTON, TEXT_BACK_BUTTON))
48 toplevel.add(bb, 0, 2, growx = 1)
49
50 while 1:
51 toplevel.setCurrent(entry1)
52 result = toplevel.run()
53 rc = bb.buttonPressed(result)
54 if rc == TEXT_BACK_CHECK:
55 screen.popWindow()
56 return INSTALL_BACK
57
58 if len(entry1.value ()) < 6:
59 ButtonChoiceWindow(screen, _("Password Length"),
60 _("The root password must be at least 6 characters long."),
61 buttons = [ TEXT_OK_BUTTON ], width = 50)
62 elif entry1.value() != entry2.value():
63 ButtonChoiceWindow(screen, _("Password Mismatch"),
64 _("The passwords you entered were different. Please try again."),
65 buttons = [ TEXT_OK_BUTTON ], width = 50)
66 elif has_bad_chars(entry1.value()):
67 ButtonChoiceWindow(screen, _("Error with Password"),
68 _("Requested password contains non-ASCII characters, "
69 "which are not allowed."),
70 buttons = [ TEXT_OK_BUTTON ], width = 50)
71 else:
72 break
73
74 entry1.set("")
75 entry2.set("")
76
77 screen.popWindow()
78 pomona.id.rootPassword["password"] = entry1.value()
79 return INSTALL_OK