You've already forked al-installer
Update password handling for user and luks setup to use ecryption
This commit is contained in:
@ -12,7 +12,7 @@
|
||||
# immutable variables {
|
||||
|
||||
readonly DIST="ArchLabs" # Linux distributor
|
||||
readonly VER="1.6.76" # Installer version
|
||||
readonly VER="1.6.77" # Installer version
|
||||
readonly LIVE="liveuser" # Live session user
|
||||
readonly MNT="/mnt/install" # Install mountpoint
|
||||
readonly ERR="/tmp/errlog" # Built-in error log
|
||||
@ -20,6 +20,7 @@ readonly EFI="/sys/firmware/efi/efivars"
|
||||
readonly TRN="/usr/share/archlabs/installer/lang"
|
||||
readonly RUN="/run/archiso/bootmnt/arch/boot"
|
||||
|
||||
readonly SALT="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
|
||||
readonly VM="$(dmesg | grep -i "hypervisor")"
|
||||
readonly KBD="$(find /usr/share/kbd/keymaps -name '*.map.gz')"
|
||||
readonly LOCALES="$(awk '/\.UTF-8/ {gsub(/# .*|#/, ""); if($1) print $1 " -"}' /etc/locale.gen)"
|
||||
@ -149,7 +150,6 @@ source_file() {
|
||||
|
||||
user_setup() {
|
||||
tput cnorm
|
||||
|
||||
local values
|
||||
values="$(dialog --stdout --no-cancel --separator '~' --ok-label "Submit" --backtitle "$BT" \
|
||||
--title " $_UserTitle " --insecure --mixedform "$_UserBody" 27 75 10 \
|
||||
@ -158,26 +158,41 @@ user_setup() {
|
||||
"$_Password2" 3 1 "" 3 $((${#_Password2} + 2)) 71 0 1 \
|
||||
"$_RootBody" 6 1 "" 6 $((${#_RootBody} + 1)) 71 0 2 \
|
||||
"$_Password" 8 1 "" 8 $((${#_Password} + 2)) 71 0 1 \
|
||||
"$_Password2" 9 1 "" 9 $((${#_Password2} + 2)) 71 0 1)"
|
||||
"$_Password2" 9 1 "" 9 $((${#_Password2} + 2)) 71 0 1 |
|
||||
openssl enc -pbkdf2 -a -salt -pass pass:$SALT)"
|
||||
[[ $? != 0 || $values == "" ]] && return 1
|
||||
|
||||
# username doesn't need to be re-encrypted
|
||||
local user
|
||||
user="$(awk -F'~' '{print $1}' <<< "$values")"
|
||||
user="$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$values" |
|
||||
awk -F'~' '{print $1}')"
|
||||
|
||||
# all of this is a bit hacky, but we don't ever want the passwords to be stored in plain text
|
||||
# so it decrypts the string '$values', gets the field we want, and re-encrypts it
|
||||
local pass pass2
|
||||
pass="$(awk -F'~' '{print $2}' <<< "$values")"
|
||||
pass2="$(awk -F'~' '{print $3}' <<< "$values")"
|
||||
pass="$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$values" |
|
||||
awk -F'~' '{print $2}' | openssl enc -pbkdf2 -a -salt -pass pass:$SALT)"
|
||||
pass2="$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$values" |
|
||||
awk -F'~' '{print $3}' | openssl enc -pbkdf2 -a -salt -pass pass:$SALT)"
|
||||
|
||||
local rpass rpass2
|
||||
rpass="$(awk -F'~' '{print $5}' <<< "$values")"
|
||||
rpass2="$(awk -F'~' '{print $6}' <<< "$values")"
|
||||
rpass="$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$values" |
|
||||
awk -F'~' '{print $5}' | openssl enc -pbkdf2 -a -salt -pass pass:$SALT)"
|
||||
rpass2="$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$values" |
|
||||
awk -F'~' '{print $6}' | openssl enc -pbkdf2 -a -salt -pass pass:$SALT)"
|
||||
|
||||
# due to the encryption the string while encrypted will not be empty
|
||||
local empty
|
||||
empty="$(openssl enc -pbkdf2 -a -salt -pass pass:$SALT <<< "")"
|
||||
|
||||
# both root passwords are empty, so use the user passwords instead
|
||||
[[ $rpass == "" && $rpass2 == "" ]] && { rpass="$pass"; rpass2="$pass2"; }
|
||||
|
||||
# make sure a username was entered and that the passwords match
|
||||
if [[ ${#user} -eq 0 || $user =~ \ |\' || $user =~ [^a-z0-9\ ] || $pass == "" || "$pass" != "$pass2" || "$rpass" != "$rpass2" ]]; then
|
||||
if [[ ${#user} -eq 0 || $user =~ \ |\' || $user =~ [^a-z0-9\ ] || $pass == "$empty" || "$pass" != "$pass2" || "$rpass" != "$rpass2" ]]; then
|
||||
if [[ $pass == "" || "$pass" != "$pass2" || "$rpass" != "$rpass2" ]]; then
|
||||
# password was left empty or doesn't match
|
||||
if [[ $pass == "" ]]; then
|
||||
if [[ $pass == "$empty" ]]; then
|
||||
msgbox "$_ErrTitle" "\nUser password CANNOT be left empty.\n$_TryAgain"
|
||||
elif [[ "$rpass" != "$rpass2" ]]; then
|
||||
msgbox "$_ErrTitle" "$_RootPassErr\n$_TryAgain"
|
||||
@ -195,7 +210,6 @@ user_setup() {
|
||||
USER_PASS="$pass"
|
||||
ROOT_PASS="$rpass"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user