Skip to content
Permalink
Browse files

Change password generation method to have more special characters and…

… try several times in case a generated password does not match complexity requirements. Make sure special characters are not espaced. Tested all those to probably not cause an issue.
  • Loading branch information
Sebastian-Roth committed Jan 25, 2019
1 parent 4d4b630 commit febd08325cf360ebe12805472e0725ca277c53dc
Showing with 15 additions and 7 deletions.
  1. +15 −7 lib/common/functions.sh
@@ -1160,11 +1160,20 @@ configureUsers() {
fi
dots "Setting up $username password"
if [[ -z $password ]]; then
[[ -f $webdirdest/lib/fog/config.class.php ]] && password="$(awk -F'[(")]' '/TFTP_FTP_PASSWORD/ {print $3}' $webdirdest/lib/fog/config.class.php)"
[[ -z $password ]] && password=$(openssl rand -base64 32)
[[ -f $webdirdest/lib/fog/config.class.php ]] && password=$(awk -F '"' -e '/TFTP_FTP_PASSWORD/,/);/{print $2}' /var/www/html/fog/lib/fog/config.class.php | grep -v "^$")

This comment has been minimized.

Copy link
@mastacontrola

mastacontrola Jan 26, 2019

Member

The /var/www/html/fog/ portion here should be changed to $webdirdest so that it's dynamic and workable for all installs.

This comment has been minimized.

Copy link
@Sebastian-Roth

Sebastian-Roth Jan 27, 2019

Author Member

Ahh, right, thanks for that!

fi
echo -e "$password\n$password" | passwd $username >>$workingdir/error_logs/fog_error_${version}.log 2>&1
errorStat $?
cnt=0
ret=999
while [[ $ret -ne 0 && $cnt -lt 10 ]]
do
[[ -z $password || $ret -ne 999 ]] && password=$(tr -cd '0-1a-zA-Z#$%&()*+,-./:<=>?@[\]^_{|}~' < /dev/urandom | fold -w12 | head -n1)
echo -e "$password\n$password" | passwd $username >>$workingdir/error_logs/fog_error_${version}.log 2>&1
ret=$?
let cnt+=1
done
errorStat $ret
unset cnt
unset ret
}
linkOptFogDir() {
if [[ ! -h /var/log/fog ]]; then
@@ -1230,7 +1239,6 @@ writeUpdateFile() {
escrouteraddress=$(echo $routeraddress | sed -e $replace)
escplainrouter=$(echo $plainrouter | sed -e $replace)
escdnsaddress=$(echo $dnsaddress | sed -e $replace)
escpassword=$(echo $password | sed -e $replace -e "s/[']{1}/'''/g")
escosid=$(echo $osid | sed -e $replace)
escosname=$(echo $osname | sed -e $replace)
escdodhcp=$(echo $dodhcp | sed -e $replace)
@@ -1293,8 +1301,8 @@ writeUpdateFile() {
sed -i "s/dnsaddress=.*/dnsaddress='$escdnsaddress'/g" $fogprogramdir/.fogsettings || \
echo "dnsaddress='$dnsaddress'" >> $fogprogramdir/.fogsettings
grep -q "password=" $fogprogramdir/.fogsettings && \
sed -i "s/password=.*/password=\"$escpassword\"/g" $fogprogramdir/.fogsettings || \
echo "password=\"$escpassword\"" >> $fogprogramdir/.fogsettings
sed -i "s/password=.*/password='$password'/g" $fogprogramdir/.fogsettings || \
echo "password='$password'" >> $fogprogramdir/.fogsettings
grep -q "osid=" $fogprogramdir/.fogsettings && \
sed -i "s/osid=.*/osid='$osid'/g" $fogprogramdir/.fogsettings || \
echo "osid='$osid'" >> $fogprogramdir/.fogsettings

0 comments on commit febd083

Please sign in to comment.
You can’t perform that action at this time.