From 0d0b3477cdbbc956b27e08c3726f89a2c46bbdf8 Mon Sep 17 00:00:00 2001 From: Phani Pavan K Date: Tue, 13 Jan 2026 20:32:34 +0530 Subject: [PATCH] lowercase usernames --- jconf | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/jconf b/jconf index 0c539b4..015de93 100755 --- a/jconf +++ b/jconf @@ -48,17 +48,18 @@ fi cmd=$1 case "$cmd" in adduser) - exist=$(awk -F: -v username="$2" '{if ($1 == username && $3 >= 1000 && $1 != "nobody") {print 1; found=1; exit}} END {if (!found) print 0}' /etc/passwd) + USER=$(echo "$2" | tr "[:upper:]" "[:lower:]") + exist=$(awk -F: -v username="$USER" '{if ($1 == username && $3 >= 1000 && $1 != "nobody") {print 1; found=1; exit}} END {if (!found) print 0}' /etc/passwd) if [ "$exist" -eq 1 ]; then - echo "$2 user already exists" + echo "$USER user already exists" else - read -rp "Do you want to create an user account $2 [y/N]:" yn + read -rp "Do you want to create an user account $USER [y/N]:" yn case $yn in [Yy]) - useradd "$2" - echo "Enter the password for $2" - passwd "$2" - echo "$2 user account created successfully" + useradd "$USER" + echo "Enter the password for $USER" + passwd "$USER" + echo "$USER user account created successfully" ;; [Nn]) exit 1 @@ -71,13 +72,13 @@ case "$cmd" in exit 1 ;; deluser) - - exist=$(awk -F: -v username="$2" '{if ($1 == username && $3 >= 1000 && $1 != "nobody") {print 1; found=1; exit}} END {if (!found) print 0}' /etc/passwd) + USER=$(echo "$2" | tr "[:upper:]" "[:lower:]") + exist=$(awk -F: -v username="$USER" '{if ($1 == username && $3 >= 1000 && $1 != "nobody") {print 1; found=1; exit}} END {if (!found) print 0}' /etc/passwd) if [ "$exist" -eq 0 ]; then - echo "$2 user doesn't exist" + echo "$USER user doesn't exist" exit 1 else - read -rp "Do you want to delete $2 user account? [y/N]:" yn + read -rp "Do you want to delete $USER user account? [y/N]:" yn case $yn in [Yy]) ;; @@ -85,11 +86,11 @@ case "$cmd" in exit 1 ;; esac - read -rp "This DELETES $2's data, are you sure? [y/N]:" yn + read -rp "This DELETES $USER's data, are you sure? [y/N]:" yn case $yn in [Yy]) - userdel -rRZ "$2"; - echo "$2 user account deleted successfully" + userdel -rRZ "$USER"; + echo "$USER user account deleted successfully" ;; [Nn]) exit 1