autodist-cgi: add available log files table for build target in SHOWLOG and implement security checks on passed urls
This commit is contained in:
parent
00adf496ba
commit
2ee18817c4
39
autodist-cgi
39
autodist-cgi
@ -7,11 +7,20 @@ AS_SECONDARY=`echo "$QUERY_STRING" | sed -n 's/^.*AS_SECONDARY=\([^&]*\).*$/\1/p
|
||||
SHOWLOG=`echo "$QUERY_STRING" | sed -n 's/^.*SHOWLOG=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
|
||||
SHOWINDEX=`echo "$QUERY_STRING" | sed -n 's/^.*SHOWINDEX=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
|
||||
LINES=`echo "$QUERY_STRING" | sed -n 's/^.*LINES=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
|
||||
FORMAT=`echo "$QUERY_STRING" | sed -n 's/^.*FORMAT=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
|
||||
|
||||
[ ! "$FORMAT" ] && FORMAT=html
|
||||
|
||||
[ "$LINES" ] || LINES=5
|
||||
[ "$AS_SECONDARY" ] && SECONDARY_ADD="&SECONDARY=1"
|
||||
|
||||
echo -e "Content-type: text/html; charset=UTF-8\n\n"
|
||||
if [ ! "$AS_SECONDARY" -a "$FORMAT" = "xml" ]; then
|
||||
echo -e "Content-type: text/xml\nPragma: no-cache\n"
|
||||
echo -n "<autodist><output><![CDATA["
|
||||
RELOADTIME=3600000
|
||||
else
|
||||
echo -e "Content-type: text/html; charset=UTF-8\n"
|
||||
fi
|
||||
|
||||
[ ! "$AS_SECONDARY" ] && echo "Build environments: [<a href=\"?NUM=\">ALL</a>]<br>"
|
||||
|
||||
@ -75,20 +84,36 @@ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
|
||||
_EOF
|
||||
echo -n "<pre><code>"
|
||||
if [ "$SHOWLOG" = "current" ]; then
|
||||
RELOADTIME=600000
|
||||
cat $LOGFILE | sed "s|<|\<|g"
|
||||
elif [ "$SHOWLOG" = "last" ]; then
|
||||
cat $LASTLOGFILE | sed "s|<|\<|g"
|
||||
else
|
||||
# Security check
|
||||
[ "${SHOWLOG/\/\.}" != "${SHOWLOG}" ] && continue
|
||||
if [ "${AUTOPORT_CHROOT[$i]}" ]; then
|
||||
BUILDLOGFILE="/var/autoport/${AUTOPORT_CHROOT[$i]}/home/${AUTOPORT_CHROOT_USER[$i]}/.autodist/log/$SHOWLOG"
|
||||
BUILDLOGDIR="/var/autoport/${AUTOPORT_CHROOT[$i]}/home/${AUTOPORT_CHROOT_USER[$i]}/.autodist/log/"
|
||||
elif [ "${AUTOPORT_NATIVE[$i]}" -o "${AUTOPORT_UPDATE[$i]}" ]; then
|
||||
BUILDLOGFILE="/var/autodist/log/$SHOWLOG"
|
||||
BUILDLOGDIR="/var/autodist/log/"
|
||||
fi
|
||||
[ -e $BUILDLOGFILE ] && cat $BUILDLOGFILE | sed "s|<|\<|g"
|
||||
if [ "${SHOWLOG/\/ok\/}" != "${SHOWLOG}" -o "${SHOWLOG/\failed\/}" != "${SHOWLOG}" ]; then
|
||||
SHOWLOGPKG=${SHOWLOG/*\/}
|
||||
[ "${SHOWLOGPKG}" ] || continue
|
||||
echo "<table><tr><td colspan=3>Last ${SHOWLOGPKG} logs:</td>"
|
||||
for t in prepare update build install send; do
|
||||
echo -n "<tr><td>$t:</td><td>"
|
||||
[ -e ${BUILDLOGDIR}${t}/ok/${SHOWLOGPKG} ] && echo -n "<td><a href=\"?NUM=$i$SECONDARY_ADD&SHOWLOG=${t}/ok/${SHOWLOGPKG}\">OK</a></td>" || echo "<td></td>"
|
||||
[ -e ${BUILDLOGDIR}${t}/failed/${SHOWLOGPKG} ] && echo -n "<td><a href=\"?NUM=$i$SECONDARY_ADD&SHOWLOG=${t}/failed/${SHOWLOGPKG}\">FAILED</a></td>" || echo "<td></td>"
|
||||
echo "</tr>"
|
||||
done
|
||||
echo "</table>"
|
||||
fi
|
||||
[ -e ${BUILDLOGDIR}${SHOWLOG} ] && cat ${BUILDLOGDIR}${SHOWLOG} | sed "s|<|\<|g"
|
||||
fi
|
||||
echo "</code></pre></div></div>"
|
||||
fi
|
||||
elif [ ! "$SHOWLOG" ]; then
|
||||
RELOADTIME=60000
|
||||
[[ "$NUM" && "$NUM" != "$i" ]] && continue
|
||||
[[ "$SECONDARY" = "$AS_SECONDARY" ]] || continue
|
||||
if [ "${AUTOPORT_UPDATE[$i]}" ]; then
|
||||
@ -220,3 +245,9 @@ if [ "$AUTOPORT_CGI_SECONDARY" -a ! "$SHOWLOG" ]; then
|
||||
fi
|
||||
fi
|
||||
[ ! "$AS_SECONDARY" ] && echo "<p><i>Generated by autodist CGI interface. Last update: `date`</i>"
|
||||
|
||||
if [ ! "$AS_SECONDARY" -a "$FORMAT" = "xml" ]; then
|
||||
echo -n "]]></output>"
|
||||
[ "$RELOADTIME" ] && echo -n "<reloadtime>$RELOADTIME</reloadtime>"
|
||||
echo "</autodist>"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user