Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rw-r--r--archinstall/lib/user_interaction.py18
2 files changed, 18 insertions, 4 deletions
diff --git a/README.md b/README.md
index 9037a5d3..c60e714a 100644
--- a/README.md
+++ b/README.md
@@ -42,7 +42,7 @@ with archinstall.Filesystem(harddrive, archinstall.GPT) as fs:
harddrive.partition[0].format('fat32')
with archinstall.luks2(harddrive.partition[1], 'luksloop', disk_password) as unlocked_device:
unlocked_device.format('btrfs')
-
+
with archinstall.Installer(unlocked_device, hostname='testmachine') as installation:
if installation.minimal_installation():
installation.add_bootloader(harddrive.partition[0])
@@ -62,7 +62,7 @@ This installer will perform the following:
* Installs a basic instance of Arch Linux *(base base-devel linux linux-firmware btrfs-progs efibootmgr)*
* Installs and configures a bootloader to partition 0.
* Install additional packages *(nano, wget, git)*
- * Installs a network-profile called [awesome](https://github.com/archlinux/archinstall/blob/master/profiles/awesome.py) *(more on network profiles in the documentation)*
+ * Installs a profile with a window manager called [awesome](https://github.com/archlinux/archinstall/blob/master/profiles/awesome.py) *(more on profile installations in the [documentation](https://python-archinstall.readthedocs.io/en/latest/archinstall/Profile.html))*.
> **Creating your own ISO with this script on it:** Follow [ArchISO](https://wiki.archlinux.org/index.php/archiso)'s guide on how to create your own ISO or use a pre-built [guided ISO](https://hvornum.se/archiso/) to skip the python installation step, or to create auto-installing ISO templates. Further down are examples and cheat sheets on how to create different live ISO's.
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index e7243a25..a58abcff 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
@@ -18,6 +18,16 @@ def get_terminal_width():
def get_longest_option(options):
return max([len(x) for x in options])
+def check_for_correct_username(username):
+ if re.match(r'^[a-z_][a-z0-9_-]*\$?$', username) and len(username) <= 32:
+ return True
+ log(
+ "The username you entered is invalid. Try again",
+ level=LOG_LEVELS.Warning,
+ fg='red'
+ )
+ return False
+
def get_password(prompt="Enter a password: "):
while (passwd := getpass.getpass(prompt)):
passwd_verification = getpass.getpass(prompt='And one more time for verification: ')
@@ -50,7 +60,9 @@ 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(' ')
-
+
+ if not check_for_correct_username(new_user):
+ 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
@@ -70,6 +82,8 @@ def ask_for_additional_users(prompt='Any additional users to install (leave blan
new_user = input(prompt).strip(' ')
if not new_user:
break
+ if not check_for_correct_username(new_user):
+ 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'):