diff --git a/Labb7/ovning3.sh b/Labb7/ovning3.sh index 308a0af..66a4f5c 100755 --- a/Labb7/ovning3.sh +++ b/Labb7/ovning3.sh @@ -12,6 +12,7 @@ Useradd="/usr/sbin/useradd" Dialog="/usr/bin/dialog" Grep="/bin/grep" Cat="/bin/cat" +Rm="/bin/rm" # Functions ask() @@ -35,7 +36,7 @@ if [ $EUID -ne 0 ]; then exit 2 fi -for bin in $Chpasswd $Useradd $Dialog $Grep $Cat; do +for bin in $Chpasswd $Useradd $Dialog $Grep $Cat $Rm; do if [ ! -x $bin ]; then echo "Can't execute $bin" exit 2 @@ -61,6 +62,9 @@ UserShell=$Input ask "Enter a password for the new user" Password=$Input +# Remove the temp file (it contains the password of latest created user) +$Rm /tmp/createuser + # Create the user and set the password $Useradd -m -s $UserShell $Username echo "${Username}:${Password}" | $Chpasswd