wok-tiny rev 48
busybox: update from wok
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Apr 30 15:50:16 2011 +0200 (2011-04-30) |
parents | 2adbda7368cd |
children | 4b736e301e90 |
files | busybox/receipt busybox/stuff/httpd_helper.sh |
line diff
1.1 --- a/busybox/receipt Sat Apr 30 15:39:10 2011 +0200 1.2 +++ b/busybox/receipt Sat Apr 30 15:50:16 2011 +0200 1.3 @@ -1,7 +1,7 @@ 1.4 # SliTaz package receipt. 1.5 1.6 PACKAGE="busybox" 1.7 -VERSION="1.18.2" 1.8 +VERSION="1.18.4" 1.9 CATEGORY="base-system" 1.10 SHORT_DESC="Busybox combines tiny versions of many common UNIX utilities." 1.11 MAINTAINER="pascal.bellard@slitaz.org" 1.12 @@ -28,6 +28,7 @@ 1.13 zmodules.u 1.14 printable.u 1.15 cmdline.u 1.16 +conspy.u 1.17 EOT 1.18 cp ../stuff/$PACKAGE-${VERSION%.*}.config .config 1.19 var="CONFIG_CROSS_COMPILER_PREFIX" 1.20 @@ -121,7 +122,7 @@ 1.21 rm -rf rootfs/tmp rootfs/var/games rootfs/var/cache \ 1.22 rootfs/bin/bootlog rootfs/etc/modprobe.d rootfs/home \ 1.23 rootfs/sbin/mktazdevs.sh rootfs/usr/bin/man \ 1.24 - rootfs/usr/share/applications rootfs/sys \ 1.25 + rootfs/usr/share/applications rootfs/sys rootfs/usr/bin/ldd \ 1.26 rootfs/etc/nsswitch.conf rootfs/etc/zcip.script \ 1.27 rootfs/etc/udhcpd.conf rootfs/etc/inetd.conf \ 1.28 rootfs/usr/lib rootfs/usr/games rootfs/usr/share/doc \
2.1 --- a/busybox/stuff/httpd_helper.sh Sat Apr 30 15:39:10 2011 +0200 2.2 +++ b/busybox/stuff/httpd_helper.sh Sat Apr 30 15:50:16 2011 +0200 2.3 @@ -1,40 +1,43 @@ 2.4 #!/bin/sh 2.5 # 2.6 -# busybox/httpd helper for shell cgi scripts 2.7 +# busybox/httpd helper for shell cgi scripts, providing: 2.8 # 2.9 -# GET [var] | POST [var] | FILE [var {name|tmpname|size|type}] 2.10 -# urlencode string | htmlentities string | httpinfo 2.11 +# GET [var [index]] | POST [var [index]] | COOKIE [var [index]] 2.12 +# FILE [var {name|tmpname|size|type}] 2.13 +# header [strings]... | urlencode string | htmlentities string | httpinfo 2.14 +# 2.15 2.16 alias urlencode='httpd -e' 2.17 2.18 +# Send headers, example : 2.19 +# header "Content-type: text/html" "Set-Cookie: name=value; HttpOnly" 2.20 header() 2.21 { 2.22 -[ -z "$1" ] && echo -e "Content-type: text/html\r\n" || echo -e "$1\r\n" 2.23 +local i 2.24 +[ -z "$1" ] && set -- "Content-type: text/html" 2.25 +for i in "$@" "" ; do echo -e "$i\r"; done 2.26 } 2.27 2.28 htmlentities() 2.29 { 2.30 -echo $1 | sed -e 's|&|\&|g' -e 's|<|\<|g' -e 's|>|\>|g' -e 's|"|\"|g' 2.31 +echo $1 | sed 's|&|\&|g;s|<|\<|g;s|>|\>|g;s|"|\"|g' 2.32 } 2.33 2.34 -GET() 2.35 +_ARRAY() 2.36 { 2.37 -[ -z "$1" ] && echo $GET__NAMES || [ -n "$GET__NAMES" ] && eval echo \$GET_$1 2.38 +[ -z "$2" ] && eval echo \$${1}__NAMES || 2.39 + [ -n "$(eval echo \$${1}__NAMES)" ] && eval echo \$${1}_${2}_${3:-1} 2.40 } 2.41 2.42 -POST() 2.43 -{ 2.44 -[ -z "$1" ] && echo $POST__NAMES || [ -n "$POST__NAMES" ] && eval echo \$POST_$1 2.45 -} 2.46 - 2.47 -FILE() 2.48 -{ 2.49 -[ -z "$1" ] && echo $FILE__NAMES || [ -n "$FILE__NAMES" ] && eval echo \$FILE_${1}_$2 2.50 -} 2.51 +GET() { _ARRAY GET "$1" $2; } 2.52 +POST() { _ARRAY POST "$1" $2; } 2.53 +FILE() { _ARRAY FILE "$1" $2; } 2.54 +COOKIE() { _ARRAY COOKIE "$1" $2; } 2.55 2.56 httpinfo() 2.57 { 2.58 local i 2.59 +local j 2.60 local x 2.61 for i in SERVER_PROTOCOL SERVER_SOFTWARE SERVER_NAME SERVER_PORT AUTH_TYPE \ 2.62 GATEWAY_INTERFACE REMOTE_HOST REMOTE_ADDR REMOTE_PORT \ 2.63 @@ -46,15 +49,20 @@ 2.64 eval x=\$$i 2.65 [ -n "$x" ] && echo "$i='$x'" 2.66 done 2.67 -for i in $GET__NAMES ; do 2.68 - echo "GET[$i]='$(GET $i)'" 2.69 +for x in GET POST COOKIE ; do 2.70 + for i in $($x) ; do 2.71 + if [ $($x $i count) -gt 1 ]; then 2.72 + for j in $(seq 1 $($x $i count)); do 2.73 + echo "$x($i,$j)='$($x $i $j)'" 2.74 + done 2.75 + else 2.76 + echo "$x($i)='$($x $i)'" 2.77 + fi 2.78 + done 2.79 done 2.80 -for i in $POST__NAMES ; do 2.81 - echo "POST[$i]='$(POST $i)'" 2.82 -done 2.83 -for i in $FILE__NAMES ; do 2.84 +for i in $(FILE) ; do 2.85 for j in name size type tmpname ; do 2.86 - echo "FILE[$i][$j]='$(FILE $i $j)'" 2.87 + echo "FILE($i,$j)='$(FILE $i $j)'" 2.88 done 2.89 done 2.90 } 2.91 @@ -63,17 +71,26 @@ 2.92 { 2.93 local i 2.94 local names 2.95 +local cnt 2.96 names="" 2.97 IFS="&" 2.98 -for i in $QUERY_STRING ; do 2.99 - names="$names ${i%%=*}" 2.100 - eval ${1}_${i%%=*}=\'$(httpd -d "${i#*=}" | sed "s/'/\'\\\\\'\'/g")\' 2.101 +for i in $2 ; do 2.102 + var=${i%%=*} 2.103 + case " $names " in 2.104 + *\ $var\ *) eval cnt=\$${1}_${var}_count ;; 2.105 + *) cnt=0 2.106 + names="$names $var" ;; 2.107 + esac 2.108 + eval ${1}_${var}_count=$((++cnt)) 2.109 + eval ${1}_${var}_$cnt=\'$(httpd -d "${i#*=}" | sed "s/'/\'\\\\\'\'/g")\' 2.110 done 2.111 unset IFS 2.112 eval ${1}__NAMES=\'${names# }\' 2.113 } 2.114 2.115 -[ "$REQUEST_METHOD" == "GET" -a -z "$GET__NAMES" ] && read_query_string GET 2.116 +[ -z "$GET__NAMES" ] && read_query_string GET "$QUERY_STRING" 2.117 +[ -z "$COOKIE_NAMES" ] && 2.118 + read_query_string COOKIE "$(echo "$HTTP_COOKIE" | sed 's/; /\&/g')" 2.119 2.120 ddcut() 2.121 { 2.122 @@ -94,7 +111,7 @@ 2.123 dd bs=1 count=$(($count - ($tmp * $page) )) 2.124 } 2.125 2.126 -if [ "$REQUEST_METHOD" == "POST" -a -z "$POST__NAMES" ]; then 2.127 +if [ "$REQUEST_METHOD$POST__NAMES" == "POST" ]; then 2.128 prefix=/tmp/httpd_post 2.129 mkdir $prefix$$ 2.130 now=$(stat -c %Y $prefix$$) 2.131 @@ -106,7 +123,7 @@ 2.132 cat > ${post}0 2.133 read delim < ${post}0 2.134 case "$delim" in 2.135 - -*) awk "/$delim/ { o+=index(\$0,\"$delim\")-1; print o } 2.136 + -*) awk "/${delim%?}/ { o+=index(\$0,\"$delim\")-1; print o } 2.137 { o+=1+length() }" < ${post}0 | while read offset; do 2.138 if [ $offset -ne 0 ]; then 2.139 ddcut $last $offset < ${post}0 > $post$n 2> /dev/null 2.140 @@ -159,8 +176,7 @@ 2.141 rm -f $i 2.142 done 2.143 rmdir $(dirname $post) ;; 2.144 - *) export QUERY_STRING="$delim" 2.145 - rm -rf $(dirname $post) 2.146 - read_query_string POST ;; 2.147 + *) rm -rf $(dirname $post) 2.148 + read_query_string POST "$delim" ;; 2.149 esac 2.150 fi