Fixed security bug by removing temp file
This commit is contained in:
parent
84d32a7900
commit
a2135827e9
@ -12,6 +12,7 @@ Useradd="/usr/sbin/useradd"
|
|||||||
Dialog="/usr/bin/dialog"
|
Dialog="/usr/bin/dialog"
|
||||||
Grep="/bin/grep"
|
Grep="/bin/grep"
|
||||||
Cat="/bin/cat"
|
Cat="/bin/cat"
|
||||||
|
Rm="/bin/rm"
|
||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
ask()
|
ask()
|
||||||
@ -35,7 +36,7 @@ if [ $EUID -ne 0 ]; then
|
|||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for bin in $Chpasswd $Useradd $Dialog $Grep $Cat; do
|
for bin in $Chpasswd $Useradd $Dialog $Grep $Cat $Rm; do
|
||||||
if [ ! -x $bin ]; then
|
if [ ! -x $bin ]; then
|
||||||
echo "Can't execute $bin"
|
echo "Can't execute $bin"
|
||||||
exit 2
|
exit 2
|
||||||
@ -61,6 +62,9 @@ UserShell=$Input
|
|||||||
ask "Enter a password for the new user"
|
ask "Enter a password for the new user"
|
||||||
Password=$Input
|
Password=$Input
|
||||||
|
|
||||||
|
# Remove the temp file (it contains the password of latest created user)
|
||||||
|
$Rm /tmp/createuser
|
||||||
|
|
||||||
# Create the user and set the password
|
# Create the user and set the password
|
||||||
$Useradd -m -s $UserShell $Username
|
$Useradd -m -s $UserShell $Username
|
||||||
echo "${Username}:${Password}" | $Chpasswd
|
echo "${Username}:${Password}" | $Chpasswd
|
||||||
|
Loading…
x
Reference in New Issue
Block a user