Changed creatation of temp file to use mktemp instead
This commit is contained in:
parent
ec6f3c7ec7
commit
87d3c6739b
@ -13,17 +13,19 @@ Dialog="/usr/bin/dialog"
|
|||||||
Grep="/bin/grep"
|
Grep="/bin/grep"
|
||||||
Cat="/bin/cat"
|
Cat="/bin/cat"
|
||||||
Rm="/bin/rm"
|
Rm="/bin/rm"
|
||||||
|
Temp=`mktemp -t createuser.XXXX` # This is safer than just creating the file
|
||||||
|
# manualy, since it will be chmod 600 now
|
||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
ask()
|
ask()
|
||||||
{
|
{
|
||||||
$Dialog --backtitle "Create new user" --inputbox "$1" 10 60\
|
$Dialog --backtitle "Create new user" --inputbox "$1" 10 60\
|
||||||
2> /tmp/createuser
|
2> $Temp
|
||||||
if [ $? -eq 255 ]; then
|
if [ $? -eq 255 ]; then
|
||||||
echo "Aborting, user hit ESC"
|
echo "Aborting, user hit ESC"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
Input=`$Cat /tmp/createuser`
|
Input=`$Cat $Temp`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,19 +55,19 @@ HowMany=`echo $Shell | wc -w` # How many shells are avaliable?
|
|||||||
|
|
||||||
$Dialog --backtitle "Create new user"\
|
$Dialog --backtitle "Create new user"\
|
||||||
--menu "Choose a shell for your new user" 14 60 $HowMany $ShellList\
|
--menu "Choose a shell for your new user" 14 60 $HowMany $ShellList\
|
||||||
2> /tmp/createuser
|
2> $Temp
|
||||||
if [ $? -eq 255 ]; then
|
if [ $? -eq 255 ]; then
|
||||||
echo "Aborting, user hit ESC"
|
echo "Aborting, user hit ESC"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
Input=`$Cat /tmp/createuser`
|
Input=`$Cat $Temp`
|
||||||
UserShell=$Input
|
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)
|
# Remove the temp file (it contains the password of latest created user)
|
||||||
$Rm /tmp/createuser
|
$Rm $Temp
|
||||||
|
|
||||||
# Create the user and set the password
|
# Create the user and set the password
|
||||||
$Useradd -m -s $UserShell $Username
|
$Useradd -m -s $UserShell $Username
|
||||||
|
@ -13,6 +13,7 @@ Zenity="/usr/bin/zenity"
|
|||||||
Grep="/bin/grep"
|
Grep="/bin/grep"
|
||||||
Cat="/bin/cat"
|
Cat="/bin/cat"
|
||||||
Rm="/bin/rm"
|
Rm="/bin/rm"
|
||||||
|
Temp=`mktemp -t createuser.XXXXXX`
|
||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
ask()
|
ask()
|
||||||
@ -22,12 +23,12 @@ ask()
|
|||||||
--add-entry="Full path of shell" \
|
--add-entry="Full path of shell" \
|
||||||
--add-entry="Comment (Full name etc)" \
|
--add-entry="Comment (Full name etc)" \
|
||||||
--add-password="Password" \
|
--add-password="Password" \
|
||||||
> /tmp/createuser
|
> $Temp
|
||||||
if [ $? -eq 1 ]; then
|
if [ $? -eq 1 ]; then
|
||||||
echo "Aborting, user hit cancel..."
|
echo "Aborting, user hit cancel..."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
Input=`$Cat /tmp/createuser`
|
Input=`$Cat $Temp`
|
||||||
}
|
}
|
||||||
|
|
||||||
extract_data()
|
extract_data()
|
||||||
@ -61,7 +62,7 @@ ask
|
|||||||
extract_data
|
extract_data
|
||||||
|
|
||||||
# Remove temp file for security reasons
|
# Remove temp file for security reasons
|
||||||
$Rm /tmp/createuser
|
$Rm $Temp
|
||||||
|
|
||||||
# Create the user and set the password
|
# Create the user and set the password
|
||||||
$Useradd -m -s $UserShell -c "$Comment" $Username
|
$Useradd -m -s $UserShell -c "$Comment" $Username
|
||||||
|
Loading…
x
Reference in New Issue
Block a user