Also checks against directory names in root (/) dir and
Checks against invalid chars as well as digits on start
Resolves: rhbz#1259284
Signed-off-by: Karel Valek <kvalek(a)redhat.com>
--
To view this pull request on github, visit https://github.com/rhinstaller/anaconda/pull/515
From: Karel Valek <kvalek(a)redhat.com>
Also checks against directory names in root (/) dir and
Checks against invalid chars as well as digits on start
Resolves: rhbz#1259284
Signed-off-by: Karel Valek <kvalek(a)redhat.com>
---
pyanaconda/ui/tui/spokes/__init__.py | 16 ++++++++--------
pyanaconda/users.py | 17 +++++++++++++++++
2 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/pyanaconda/ui/tui/spokes/__init__.py b/pyanaconda/ui/tui/spokes/__init__.py
index 61f4486..e6baf31 100644
--- a/pyanaconda/ui/tui/spokes/__init__.py
+++ b/pyanaconda/ui/tui/spokes/__init__.py
@@ -21,7 +21,7 @@
from pyanaconda.ui.tui import simpleline as tui
from pyanaconda.ui.tui.tuiobject import TUIObject, YesNoDialog
from pyanaconda.ui.common import Spoke, StandaloneSpoke, NormalSpoke
-from pyanaconda.users import validatePassword, cryptPassword
+from pyanaconda.users import validatePassword, cryptPassword, check_name
import re
from collections import namedtuple
from pyanaconda.iutil import setdeepattr, getdeepattr
@@ -98,11 +98,7 @@ class NormalTUISpoke(TUISpoke, NormalSpoke):
# Inherit abstract methods from NormalTUISpoke
# pylint: disable=abstract-method
class EditTUIDialog(NormalTUISpoke):
- """Spoke/dialog used to read new value of textual or password data
-
- To override the wrong input message set the wrong_input_message attribute
- to a translated string.
- """
+ """Spoke/dialog used to read new value of textual or password data"""
title = N_("New value")
PASSWORD = re.compile(".*")
@@ -184,17 +180,21 @@ def prompt(self, entry = None):
return _("Enter new value for '%s' and press enter\n") % entry.title
def input(self, entry, key):
- if entry.aux.match(key):
+ valid, err_msg = check_name(key)
+ if entry.aux.match(key) and valid:
self.value = key
self.close()
return True
else:
+ self.wrong_input_message = err_msg
if self.wrong_input_message:
print(self.wrong_input_message)
else:
- print(_("You have provided an invalid value\n"))
+ print(_("You have provided an invalid user name: %s\n"
+ "Tip: Keep your user name shorter than 32 characters and do not use spaces.\n") % key)
return NormalTUISpoke.input(self, entry, key)
+
class OneShotEditTUIDialog(EditTUIDialog):
"""The same as EditTUIDialog, but closes automatically after
the value is read
diff --git a/pyanaconda/users.py b/pyanaconda/users.py
index f53e705..731bcd3 100644
--- a/pyanaconda/users.py
+++ b/pyanaconda/users.py
@@ -27,7 +27,9 @@
import pwquality
from pyanaconda.iutil import strip_accents
from pyanaconda.constants import PASSWORD_MIN_LEN
+
from pyanaconda.errors import errorHandler, PasswordCryptError, ERROR_RAISE
+import re
import logging
log = logging.getLogger("anaconda")
@@ -166,6 +168,21 @@ def validatePassword(pw, user="root", settings=None, minlen=None):
return (valid, strength, message)
+def check_name(in_name):
+ ign_cond = {r"^[\d]": "User name cannot start with a digit: ",
+ r"[^A-Za-z0-9\s]": "User name cannot contain any non-alphanumerical character: "}
+
+ for sys_name in os.listdir("/") + ["root", "home", "daemon", "system"]:
+ if in_name in sys_name:
+ return (False, "Username is reserved for system: %s" % sys_name)
+
+ for cond in ign_cond:
+ match = re.search(cond, in_name)
+ if match:
+ return (False, ign_cond[cond] + "'%s'" % match.group())
+
+ return (True, None)
+
def guess_username(fullname):
fullname = fullname.split()
--
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/e1bf4e3270b3e32aaeeb8bc69683…
>Please fix this pylint error. Jenkins is complaining about it.
************* Module ../pyanaconda/ui/tui/spokes/network.py
E0611: 24,0: : No name 'environs' in module 'pyanaconda.flags'
Yep, that's indeed wrong. Should be fixed now.
--
To view this pull request on github, visit https://github.com/rhinstaller/anaconda/pull/652
At the moment the network spoke tries to trigger a payload reset when network settings are changed even if running inside of Initial Setup. This is of course wrong, as there is no payload instance in Initial Setup, which can trigger a lot of various issues (crashes, weird log messages, etc.).
The first patch adds the environs flag so that spokes can easily check the environment at runtime. It also gets rid of the old _environs hub property.
The second patch then uses the environs flag to only trigger the payload reset when the network spoke is run from inside of Anaconda.
--
To view this pull request on github, visit https://github.com/rhinstaller/anaconda/pull/652
From: Martin Kolman <mkolman(a)redhat.com>
This makes the identifier easily accessible to Anaconda & addons
in case they want to change their behavior based on the current
runtime environment.
Related: rhbz#1270354
---
pyanaconda/flags.py | 4 +++-
pyanaconda/ui/common.py | 3 ---
pyanaconda/ui/gui/hubs/__init__.py | 2 +-
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/pyanaconda/flags.py b/pyanaconda/flags.py
index d647239..8a97f95 100644
--- a/pyanaconda/flags.py
+++ b/pyanaconda/flags.py
@@ -20,7 +20,7 @@
import selinux
import shlex
import glob
-from pyanaconda.constants import SELINUX_DEFAULT, CMDLINE_APPEND
+from pyanaconda.constants import SELINUX_DEFAULT, CMDLINE_APPEND, ANACONDA_ENVIRON
from collections import OrderedDict
import logging
@@ -76,6 +76,8 @@ def __init__(self, read_cmdline=True):
self.nosave_logs = False
# single language options
self.singlelang = False
+ # current runtime environments
+ self.environs = [ANACONDA_ENVIRON]
# parse the boot commandline
self.cmdline = BootArgs()
# Lock it down: no more creating new flags!
diff --git a/pyanaconda/ui/common.py b/pyanaconda/ui/common.py
index e4f994e..39e7bb3 100644
--- a/pyanaconda/ui/common.py
+++ b/pyanaconda/ui/common.py
@@ -495,9 +495,6 @@ def __init__(self, storage, payload, instclass):
self.paths = {}
self._spokes = {}
- # spokes for which environments this hub should collect?
- self._environs = [ANACONDA_ENVIRON]
-
@abstractproperty
def data(self):
pass
diff --git a/pyanaconda/ui/gui/hubs/__init__.py b/pyanaconda/ui/gui/hubs/__init__.py
index 2563300..4aaab17 100644
--- a/pyanaconda/ui/gui/hubs/__init__.py
+++ b/pyanaconda/ui/gui/hubs/__init__.py
@@ -114,7 +114,7 @@ def _createBox(self):
selectors = []
for spokeClass in sorted(cats_and_spokes[c], key=lambda s: s.title):
# Check if this spoke is to be shown in the supported environments
- if not any(spokeClass.should_run(environ, self.data) for environ in self._environs):
+ if not any(spokeClass.should_run(environ, self.data) for environ in flags.environs):
continue
# Create the new spoke and populate its UI with whatever data.
--
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/443f356c38f20847d3a31bf09625…
Also checks against directory names in root (/) dir and
Checks against invalid chars as well as digits on start
Resolves: rhbz#1259284
Signed-off-by: Karel Valek <kvalek(a)redhat.com>
--
To view this pull request on github, visit https://github.com/rhinstaller/anaconda/pull/515
Please fix this pylint error. Jenkins is complaining about it.
``************* Module ../pyanaconda/ui/tui/spokes/network.py``
``E0611: 24,0: : No name 'environs' in module 'pyanaconda.flags'``
--
To view this pull request on github, visit https://github.com/rhinstaller/anaconda/pull/652