Skip to content

Commit

Permalink
firstlogin: quote values if space is legal (armbian#6942)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkt628 authored Jul 14, 2024
1 parent c377ba3 commit e7b0c3f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/bsp/common/usr/lib/armbian/armbian-firstlogin
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,10 @@ add_user() {
REPEATS=3
while [ -f "/root/.not_logged_in_yet" ]; do
echo -e "\nPlease provide a username (eg. your first name): \c"
if [ -z $PRESET_USER_NAME ];then
if [ -z "$PRESET_USER_NAME" ];then
read -r -e username
else
username=$PRESET_USER_NAME
username="$PRESET_USER_NAME"
fi
if ! grep '^[a-zA-Z][a-zA-Z0-9]*$' <<< "$username" > /dev/null; then
echo -e "\n\x1B[91mError\x1B[0m: illegal characters in username"
Expand All @@ -544,17 +544,17 @@ add_user() {
done

while [ -f "/root/.not_logged_in_yet" ]; do
if [ -z $PRESET_USER_PASSWORD ];then
if [ -z "$PRESET_USER_PASSWORD" ];then
read_password "Create user ($username)"
else
password=$PRESET_USER_PASSWORD
password="$PRESET_USER_PASSWORD"
fi
first_input="$password"
echo ""
if [ -z $PRESET_USER_PASSWORD ];then
if [ -z "$PRESET_USER_PASSWORD" ];then
read_password "Repeat user ($username)"
else
password=$PRESET_USER_PASSWORD
password="$PRESET_USER_PASSWORD"
fi
second_input="$password"
echo ""
Expand All @@ -568,10 +568,10 @@ add_user() {
fi
fi
echo -e ""
if [ -z $PRESET_DEFAULT_REALNAME ];then
if [ -z "$PRESET_DEFAULT_REALNAME" ];then
read -r -e -p "Please provide your real name: " -i "${RealUserName^}" RealName
else
RealName=$PRESET_DEFAULT_REALNAME
RealName="$PRESET_DEFAULT_REALNAME"
fi

adduser --quiet --disabled-password --home /home/"$RealUserName" --gecos "$RealName" "$RealUserName"
Expand Down Expand Up @@ -665,13 +665,13 @@ if [[ -f /root/.not_logged_in_yet && -n $(tty) ]]; then
REPEATS=3
while [ -f "/root/.not_logged_in_yet" ]; do
. /root/.not_logged_in_yet
if [ -z $PRESET_ROOT_PASSWORD ];then
if [ -z "$PRESET_ROOT_PASSWORD" ];then
read_password "Create root"
else
if [ "$(who am i | awk '{print $2}')" != "tty1" ];then
exit
fi
password=$PRESET_ROOT_PASSWORD
password="$PRESET_ROOT_PASSWORD"
fi

# only allow one login. Once you enter root password, kill others.
Expand All @@ -680,10 +680,10 @@ if [[ -f /root/.not_logged_in_yet && -n $(tty) ]]; then

first_input="$password"
echo ""
if [ -z $PRESET_ROOT_PASSWORD ];then
if [ -z "$PRESET_ROOT_PASSWORD" ];then
read_password "Repeat root"
else
password=$PRESET_ROOT_PASSWORD
password="$PRESET_ROOT_PASSWORD"
fi
second_input="$password"
echo ""
Expand Down

0 comments on commit e7b0c3f

Please sign in to comment.