webbuild: login fix for problem when password is changed on main site

This commit is contained in:
Silvan Calarco 2017-06-19 14:39:08 +02:00
parent c3cbf7c0e8
commit a6d6fd03e4
2 changed files with 30 additions and 15 deletions

View File

@ -49,18 +49,14 @@ if [ "$USER" ]; then
if [ "$SECRET" = "$USER_SECRET" ]; then if [ "$SECRET" = "$USER_SECRET" ]; then
[ "$REMOTE_ADDR" = "127.0.0.1" -o "$USER_SECRET" ] && USER_ENABLED=1 || USER_ENABLED= [ "$REMOTE_ADDR" = "127.0.0.1" -o "$USER_SECRET" ] && USER_ENABLED=1 || USER_ENABLED=
elif [ "$REQUEST" = "password" ]; then elif [ "$REQUEST" = "password" ]; then
if [ "$USER_SECRET" ]; then
/usr/libexec/webbuild-checkpassword "$PASSWORD" "$USER_SECRET" 2>/dev/null
else
/usr/libexec/webbuild-checkpassword "$PASSWORD" "$SECRET" 2>/dev/null /usr/libexec/webbuild-checkpassword "$PASSWORD" "$SECRET" 2>/dev/null
fi
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
if [ ! "$USER_SECRET" ]; then USER_SECRET=$SECRET
tmpfile=`mktemp --suffix=webbuildtmp` tmpfile=`mktemp --suffix=webbuildtmp`
cat $WEBBUILD_STATEDIR/users/$USER.conf > $tmpfile cat $WEBBUILD_STATEDIR/users/$USER.conf > $tmpfile
sed -i "/USER_SECRET=/d" $tmpfile
echo "USER_SECRET='$SECRET'" >> $tmpfile echo "USER_SECRET='$SECRET'" >> $tmpfile
$SUDO_WRAPPER 0 local "$USER" "" "mv $tmpfile $WEBBUILD_STATEDIR/users/$USER.conf" $SUDO_WRAPPER 0 local "$USER" "" "mv $tmpfile $WEBBUILD_STATEDIR/users/$USER.conf"
fi
USER_ENABLED=1 USER_ENABLED=1
else else
USER_ENABLED= USER_ENABLED=
@ -104,7 +100,7 @@ elif [ "${REQUEST:0:7}" != "refresh" ]; then
echo -n "<packages> </packages>" echo -n "<packages> </packages>"
echo -n "<editcontrols> </editcontrols>" echo -n "<editcontrols> </editcontrols>"
echo -n "<showlogcontrols> </showlogcontrols>" echo -n "<showlogcontrols> </showlogcontrols>"
echo -n "<editor> </editor>" + echo -n "<editor> </editor>"
echo -n "<operationpanel> </operationpanel>" echo -n "<operationpanel> </operationpanel>"
echo -n "</webbuild>" echo -n "</webbuild>"
exit exit
@ -221,7 +217,7 @@ if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshsocial" -o ! "$USER" ]; then
if [ ! "$FROMID" -o "$FROMID" = "0" -o "$FROMID" = "NaN" ]; then if [ ! "$FROMID" -o "$FROMID" = "0" -o "$FROMID" = "NaN" ]; then
# Find id of last row - 25 # Find id of last row - 25
if [ "$USER" ]; then if [ "$USER" ]; then
LASTID_QUERY="SELECT id FROM (SELECT id FROM social_log WHERE user!='$USER' ORDER BY id DESC LIMIT 25) sub ORDER BY id ASC LIMIT 1;" LASTID_QUERY="SELECT id FROM (SELECT id FROM social_log WHERE id!='$USER' ORDER BY id DESC LIMIT 25) sub ORDER BY id ASC LIMIT 1;"
else else
LASTID_QUERY="SELECT id FROM (SELECT id FROM social_log WHERE target!='$DEVELOPERS' ORDER BY id DESC LIMIT 25) sub ORDER BY id ASC LIMIT 1;" LASTID_QUERY="SELECT id FROM (SELECT id FROM social_log WHERE target!='$DEVELOPERS' ORDER BY id DESC LIMIT 25) sub ORDER BY id ASC LIMIT 1;"
fi fi
@ -362,6 +358,7 @@ fi
# refresh processes list # refresh processes list
if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshjobs" ]; then if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshjobs" ]; then
echo -n "<processes><![CDATA[" echo -n "<processes><![CDATA["
if [ "$USER_ADMIN" -a -s $WEBBUILD_STATEDIR/requests ]; then if [ "$USER_ADMIN" -a -s $WEBBUILD_STATEDIR/requests ]; then
echo -n "<div align=left class=processes><b>Pending admin requests:</b>" echo -n "<div align=left class=processes><b>Pending admin requests:</b>"
@ -400,27 +397,44 @@ if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshjobs" ]; then
tac $WEBBUILD_STATEDIR/processes | \ tac $WEBBUILD_STATEDIR/processes | \
while read line; do while read line; do
set -- $line set -- $line
RETCODE=$6 CMDPID=$1
CMDUSER=$2
PROCESSLOG=$5 PROCESSLOG=$5
ORIGRETCODE=$6
NOTIFIED=
if [ "${ORIGRETCODE: -1}" == "+" ]; then
NOTIFIED=1
RETCODE="${ORIGRETCODE::-1}"
else
RETCODE=$ORIGRETCODE
fi
numprocess=$(($numprocess + 1)) numprocess=$(($numprocess + 1))
cmdline=`echo "$line" | sed "s|$1 $2 $3 $4 $5 $RETCODE ||"` cmdline=`echo "$line" | sed "s|$1 $2 $3 $4 $5 $ORIGRETCODE ||"`
cmdline=`echo "$cmdline" | sed "s| --colors web||"` cmdline=`echo "$cmdline" | sed "s| --colors web||"`
PACKAGE_ENCODED=`cgi_encodevar $4` PACKAGE_ENCODED=`cgi_encodevar $4`
[ "$STATE_JOBSSHOWALL" = "1" -o "$USER" = "$2" ] || continue [ "$STATE_JOBSSHOWALL" = "1" -o "$USER" = "$2" ] || continue
if [ $RETCODE -eq 256 -a -e /proc/$1 ]; then if [ $RETCODE -eq 256 -a -e /proc/$1 ]; then
echo -n "<img style=\"margin-top:-1px;margin-right:2px;\" width=10 height=10 src=\"/images/inprogress.gif\" alt=\"running...\" title=\"running...\">" echo -n "<img style=\"margin-top:-1px;margin-right:2px;\" width=10 height=10 src=\"/images/inprogress.gif\" alt=\"running...\" title=\"running...\">"
elif [ ! -e $PROCESSLOG ]; then elif [ ! -e $PROCESSLOG ]; then
sed -i "\,$1 $USER.* $PROCESSLOG ,d" $WEBBUILD_STATEDIR/processes sed -i "\,$CMDPID $CMDUSER.* $PROCESSLOG ,d" $WEBBUILD_STATEDIR/processes
continue continue
else else
if [ $RETCODE -eq 256 ]; then if [ $RETCODE -eq 256 ]; then
$SUDO_WRAPPER finishprocess $1 "$USER" $5 $SUDO_WRAPPER finishprocess $1 "$USER" $5
RETCODE=$? RETCODE=$?
fi fi
# Process finished: add + to retcode to report notification
if [ ! "$NOTIFIED" ]; then
sed -i "s|^\($CMDPID $CMDUSER.* $PROCESSLOG $RETCODE\)|\1\+|" $WEBBUILD_STATEDIR/processes
fi
if [ $RETCODE -eq 0 ]; then if [ $RETCODE -eq 0 ]; then
[ "$NOTIFIED" ] || \
social_log "SUSER=$USER STYPE=job SEMAIL=$USER_EMAIL STEXT=\"''$cmdline'' <b>succesfully completed</b>!\" STIME=`date +%s`" >> /tmp/y
# echo -n "<font color=lightgreen><b>OK</b></font>" # echo -n "<font color=lightgreen><b>OK</b></font>"
echo -n "<img style=\"margin-top:-1px;margin-right:2px;\" src=\"/images/ok.png\" width=10 height=10 alt=\"OK\" title=\"Job successfully completed\">" echo -n "<img style=\"margin-top:-1px;margin-right:2px;\" src=\"/images/ok.png\" width=10 height=10 alt=\"OK\" title=\"Job successfully completed\">"
else else
[ "$NOTIFIED" ] || \
social_log "SUSER=$USER STYPE=job SEMAIL=$USER_EMAIL STEXT=\"''$cmdline'' <b>failed</b>\" STIME=`date +%s`"
# echo -n "<font color=red><b>ERROR ($RETCODE)</b></font>" # echo -n "<font color=red><b>ERROR ($RETCODE)</b></font>"
echo -n "<img style=\"margin-top:-1px;margin-right:2px;\" src=\"/images/fail.png\" width=10 height=10 alt=\"ERROR\" title=\"Job returned with error $RETCODE\">" echo -n "<img style=\"margin-top:-1px;margin-right:2px;\" src=\"/images/fail.png\" width=10 height=10 alt=\"ERROR\" title=\"Job returned with error $RETCODE\">"
fi fi

View File

@ -259,6 +259,7 @@ class PasswordHash {
} }
$wp_hasher = new PasswordHash(8, TRUE); $wp_hasher = new PasswordHash(8, TRUE);
echo $wp_hasher->HashPassword($argv[1]);
if ($wp_hasher->CheckPassword($argv[1], $argv[2]) == "1") if ($wp_hasher->CheckPassword($argv[1], $argv[2]) == "1")
exit(0); exit(0);
else else