[master][PATCH] Warn user if entering LUKS password with non-ASCII characters (#1039168)
Vratislav Podzimek
vpodzime at redhat.com
Wed Jan 8 10:35:48 UTC 2014
Non-ASCII characters are likely to cause issues on boot where a VConsole keymap
is active instead of the X layout that was active during installation.
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
pyanaconda/constants.py | 4 ++++
pyanaconda/ui/gui/spokes/lib/passphrase.py | 15 +++++++++++++--
pyanaconda/users.py | 5 ++---
3 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/pyanaconda/constants.py b/pyanaconda/constants.py
index 8e3111d..3df73ee 100644
--- a/pyanaconda/constants.py
+++ b/pyanaconda/constants.py
@@ -19,6 +19,7 @@
# Author(s): Erik Troan <ewt at redhat.com>
#
+import string
from pyanaconda.i18n import N_
SELINUX_DEFAULT = 1
@@ -147,3 +148,6 @@ PASSWORD_STRENGTH_DESC = [N_("Empty"), N_("Weak"), N_("Fair"), N_("Good"), N_("S
# the number of seconds we consider a noticeable freeze of the UI
NOTICEABLE_FREEZE = 0.1
+
+# all ASCII characters
+PW_ASCII_CHARS = string.digits + string.ascii_letters + string.punctuation + " "
diff --git a/pyanaconda/ui/gui/spokes/lib/passphrase.py b/pyanaconda/ui/gui/spokes/lib/passphrase.py
index c3cc119..dcd61c5 100644
--- a/pyanaconda/ui/gui/spokes/lib/passphrase.py
+++ b/pyanaconda/ui/gui/spokes/lib/passphrase.py
@@ -24,7 +24,7 @@ from gi.repository import Gtk, Gdk
import pwquality
from pyanaconda.ui.gui import GUIObject
-
+from pyanaconda.constants import PW_ASCII_CHARS
from pyanaconda.i18n import _, N_
__all__ = ["PassphraseDialog"]
@@ -131,7 +131,8 @@ class PassphraseDialog(GUIObject):
def on_passphrase_changed(self, entry):
self._update_passphrase_strength()
- if entry.get_text() and entry.get_text() == self._confirm_entry.get_text():
+ passphrase = entry.get_text()
+ if passphrase and passphrase == self._confirm_entry.get_text():
self._set_entry_icon(self._confirm_entry, "", "")
self._save_button.set_sensitive(True)
else:
@@ -140,6 +141,16 @@ class PassphraseDialog(GUIObject):
if not self._pwq_error:
self._set_entry_icon(entry, "", "")
+ can_override_icon = entry.get_icon_name(Gtk.EntryIconPosition.SECONDARY)\
+ in ["gtk-dialog-warning", "", None]
+ if can_override_icon:
+ # no other icon set, make non-ASCII warning (lowest priority) effective
+ if passphrase and any(char not in PW_ASCII_CHARS for char in passphrase):
+ self._set_entry_icon(entry, "gtk-dialog-warning",
+ _("contains non-ASCII characters"))
+ else:
+ self._set_entry_icon(entry, "", "")
+
def on_passphrase_editing_done(self, entry, *args):
if self._pwq_error:
icon = "gtk-dialog-error"
diff --git a/pyanaconda/users.py b/pyanaconda/users.py
index e61a787..0988c11 100644
--- a/pyanaconda/users.py
+++ b/pyanaconda/users.py
@@ -30,7 +30,7 @@ from pyanaconda import iutil
import pwquality
from pyanaconda.iutil import strip_accents
from pyanaconda.i18n import _
-from pyanaconda.constants import PASSWORD_MIN_LEN
+from pyanaconda.constants import PASSWORD_MIN_LEN, PW_ASCII_CHARS
import logging
log = logging.getLogger("anaconda")
@@ -154,9 +154,8 @@ def validatePassword(pw, user="root", settings=None):
validatePassword.pwqsettings.minlen = PASSWORD_MIN_LEN
settings = validatePassword.pwqsettings
- legal = string.digits + string.ascii_letters + string.punctuation + " "
for letter in pw:
- if letter not in legal:
+ if letter not in PW_ASCII_CHARS:
message = _("Requested password contains "
"non-ASCII characters, which are "
"not allowed.")
--
1.8.4.2
More information about the anaconda-patches
mailing list