]>
git.ipfire.org Git - ipfire-3.x.git/blob - src/pomona/tui_userauth.py
2 # userauth_text.py: text mode authentication setup dialogs
4 # Copyright 2000-2002 Red Hat, Inc.
6 # This software may be freely redistributed under the terms of the GNU
7 # library public license.
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.
15 from constants
import *
18 _
= lambda x
: gettext
.ldgettext("pomona", x
)
20 def has_bad_chars(pw
):
21 allowed
= string
.digits
+ string
.ascii_letters
+ string
.punctuation
+ " "
23 if letter
not in allowed
:
27 class RootPasswordWindow
:
28 def __call__ (self
, screen
, pomona
):
29 toplevel
= GridFormHelp(screen
, _("Root Password"), "rootpw", 1, 3)
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))
38 entry1
= Entry(24, password
= 1, text
= pomona
.id.rootPassword
["password"])
39 entry2
= Entry(24, password
= 1, text
= pomona
.id.rootPassword
["password"])
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))
47 bb
= ButtonBar(screen
, (TEXT_OK_BUTTON
, TEXT_BACK_BUTTON
))
48 toplevel
.add(bb
, 0, 2, growx
= 1)
51 toplevel
.setCurrent(entry1
)
52 result
= toplevel
.run()
53 rc
= bb
.buttonPressed(result
)
54 if rc
== TEXT_BACK_CHECK
:
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)
78 pomona
.id.rootPassword
["password"] = entry1
.value()