Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib
diff options
context:
space:
mode:
authorSecondThundeR <awayfromgalaxy@gmail.com>2021-04-05 18:38:21 +0300
committerSecondThundeR <awayfromgalaxy@gmail.com>2021-04-05 18:38:21 +0300
commit5de1154ce9708f770bacae5faa2ef3c3eea4c2e2 (patch)
treeb0d2d1d45ef5828c88b3622f2f5b14716072663b /archinstall/lib
parent992ee851d4d57cdd11f490123f94c2c23f8c1e76 (diff)
Replace lowercase conversion with correct checking
Diffstat (limited to 'archinstall/lib')
-rw-r--r--archinstall/lib/user_interaction.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index e5cdb670..30008fad 100644
--- a/archinstall/lib/user_interaction.py
+++ b/archinstall/lib/user_interaction.py
@@ -1,4 +1,4 @@
-import getpass, pathlib, os, shutil
+import getpass, pathlib, os, shutil, re
from .exceptions import *
from .profiles import Profile
from .locale_helpers import search_keyboard_layout
@@ -49,8 +49,15 @@ def print_large_list(options, padding=5, margin_bottom=0, separator=': '):
def ask_for_superuser_account(prompt='Create a required super-user with sudo privileges: ', forced=False):
while 1:
- new_user = input(prompt).strip(' ').lower()
-
+ new_user = input(prompt).strip(' ')
+
+ if not re.match('[a-z_][a-z0-9_-]*[$]?', new_user) or len(new_user) > 32:
+ log(
+ "The username you entered is invalid. Try again",
+ level=LOG_LEVELS.Warning,
+ fg='red'
+ )
+ continue
if not new_user and forced:
# TODO: make this text more generic?
# It's only used to create the first sudo user when root is disabled in guided.py
@@ -67,9 +74,16 @@ def ask_for_additional_users(prompt='Any additional users to install (leave blan
super_users = {}
while 1:
- new_user = input(prompt).strip(' ').lower()
+ new_user = input(prompt).strip(' ')
if not new_user:
break
+ if not re.match('[a-z_][a-z0-9_-]*[$]?', new_user) or len(new_user) > 32:
+ log(
+ "The username you entered is invalid. Try again",
+ level=LOG_LEVELS.Warning,
+ fg='red'
+ )
+ continue
password = get_password(prompt=f'Password for user {new_user}: ')
if input("Should this user be a sudo (super) user (y/N): ").strip(' ').lower() in ('y', 'yes'):