#!/bin/bash -E URL="/apt-sec" sURL="\/apt-sec" WD="/srv/http/htdocs/apt-sec/html" . pieces.sh . libcgi2.sh ## ## do the work ## cgi_getvars GET action cgi_getvars GET object #cgi_getvars BOTH file ## debugging # echo '
' # set |sed 's/\<\;/'; # env |sed 's/\<\;/'; # echo '' ## input variable cavity search object=$(echo "$object"|tr -d "<>;|#\"'") action=$(echo "$action"|tr -d "<>;|#\"'") # disable during aptsec mirroring.. if lockfile-check /var/lock/aptsec-update; then output="$UPDATE_MSG" else case $action in "sys") if [ "$REQUEST_METHOD" != "POST" ]; then output="
$FILE_FORM
" else tmp="$(tempfile)"; # crude hack: delete last 2 and first 4 lines to extract binary file #echo -n "$QUERY_STRING_POST"|tac|tail -n +3|tac|tail -n +5 > $tmp cat - |tac|tail -n +3|tac|tail -n +5 > $tmp if grep -q 'boot_aggregate' "$tmp"; then output="$(../apt-sec attest $tmp)" else output="$(../apt-sec status $tmp)" fi rm $tmpfile sum=$(echo "$output"|grep -A99 ^Packages\ with) lines=$(($(echo "$output"|wc -l|awk '{print $1}')-$(echo "$sum"|wc -l|awk '{print $1}'))) log=$(echo -e "\n\nAssessment details:"; echo "$output"|head -$lines) output="$(echo "$sum$log"|sed "s/MTTFl/MTTF\λ<\/sub>/")" output="$output
" fi ;; "jmp") echo "$HTTP_HEADER" echo '' exit ;; "pkg") case $object in "") output="$OBJECT_FORM
" ;; *) #echo "AA${object}AA" #echo -n "$object"|wc -c #[[ "$object" =~ [a-z,A-Z,0-9] ]] && echo true; if [ $(echo -n "$object"|wc -c) -eq 40 ] && [[ "$object" =~ [a-z,A-Z,0-9] ]]; then output="$(../apt-sec sha1 $object)" output="" output="
$output
" ;; "about") output="$(../apt-sec about)" output="