wok-4.x rev 9535
busybox/httpd: add directory list support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Apr 08 18:12:43 2011 +0200 (2011-04-08) |
parents | a5912cbfcc85 |
children | e597e4912614 |
files | busybox/receipt busybox/stuff/busybox-1.18-httpd.u busybox/stuff/busybox-1.18.config |
line diff
1.1 --- a/busybox/receipt Fri Apr 08 17:22:34 2011 +0200 1.2 +++ b/busybox/receipt Fri Apr 08 18:12:43 2011 +0200 1.3 @@ -28,6 +28,7 @@ 1.4 printable.u 1.5 cmdline.u 1.6 conspy.u 1.7 +httpd.u 1.8 EOT 1.9 cp $stuff/$PACKAGE-${VERSION%.*}.config .config 1.10 }
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/busybox/stuff/busybox-1.18-httpd.u Fri Apr 08 18:12:43 2011 +0200 2.3 @@ -0,0 +1,106 @@ 2.4 +This patch allows to run a script to list the directory with httpd 2.5 + 2.6 +Install /etc/httpd.conf, /var/www/cgi-bin/list.sh and try ! 2.7 + 2.8 +===>8=== /etc/httpd.conf ===>8=== 2.9 +H:/var/www 2.10 +*.sh:/bin/sh 2.11 +L:/cgi-bin/list.sh 2.12 +===>8=== /var/www/cgi-bin/list.sh ===>8=== 2.13 +#!/bin/sh 2.14 + 2.15 +eval ${QUERY_STRING/&/;} 2.16 +path=$(dirname /$url) 2.17 + 2.18 +unix2dos <<EOT 2.19 +Content-type: text/html 2.20 + 2.21 +<!DOCTYPE html> 2.22 +<html xmlns="http://www.w3.org/1999/xhtml"> 2.23 +<head> 2.24 + <title>Index of $path</title> 2.25 +</head> 2.26 +<body> 2.27 + <h1>Index of $path</h1> 2.28 + <ul> 2.29 +$(cd $home$path && { [ "$path" != "/" ] && echo "../" ; ls -p; } | \ 2.30 + sed 's|.*| <li><a href="&">&</a></li>|') 2.31 + </ul> 2.32 +</body> 2.33 +</html> 2.34 +EOT 2.35 +===>8======>8======>8======>8======>8=== 2.36 + 2.37 +--- busybox-1.18.4/networking/Config.src 2.38 ++++ busybox-1.18.4/networking/Config.src 2.39 +@@ -216,6 +216,14 @@ 2.40 + This option allows scripts and executables to be invoked 2.41 + when specific URLs are requested. 2.42 + 2.43 ++config FEATURE_HTTPD_LISTING 2.44 ++ bool "Support for directory listing through a CGI script" 2.45 ++ default y 2.46 ++ depends on FEATURE_HTTPD_CGI 2.47 ++ help 2.48 ++ This option allows to run a script to list the directory 2.49 ++ content. 2.50 ++ 2.51 + config FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR 2.52 + bool "Support for running scripts through an interpreter" 2.53 + default y 2.54 + 2.55 +--- busybox-1.18.4/networking/httpd.c 2.56 ++++ busybox-1.18.4/networking/httpd.c 2.57 +@@ -42,6 +42,7 @@ 2.58 + * D:* # Deny from other IP connections 2.59 + * E404:/path/e404.html # /path/e404.html is the 404 (not found) error page 2.60 + * I:index.html # Show index.html when a directory is requested 2.61 ++ * L:/path/list # List directory file from $url and $home arguments 2.62 + * 2.63 + * P:/url:[http://]hostname[:port]/new/path 2.64 + * # When /urlXXXXXX is requested, reverse proxy 2.65 +@@ -240,6 +241,7 @@ 2.66 + const char *opt_c_configFile; 2.67 + const char *home_httpd; 2.68 + const char *index_page; 2.69 ++ const char *listing; 2.70 + 2.71 + const char *found_mime_type; 2.72 + const char *found_moved_temporarily; 2.73 +@@ -291,6 +293,7 @@ 2.74 + #define opt_c_configFile (G.opt_c_configFile ) 2.75 + #define home_httpd (G.home_httpd ) 2.76 + #define index_page (G.index_page ) 2.77 ++#define listing (G.listing ) 2.78 + #define found_mime_type (G.found_mime_type ) 2.79 + #define found_moved_temporarily (G.found_moved_temporarily) 2.80 + #define last_mod (G.last_mod ) 2.81 +@@ -579,6 +582,13 @@ 2.82 + continue; 2.83 + } 2.84 + 2.85 ++#if ENABLE_FEATURE_HTTPD_LISTING 2.86 ++ if (flag == FIRST_PARSE && ch == 'L') { 2.87 ++ listing = xstrdup(after_colon); 2.88 ++ continue; 2.89 ++ } 2.90 ++#endif 2.91 ++ 2.92 + /* do not allow jumping around using H in subdir's configs */ 2.93 + if (flag == FIRST_PARSE && ch == 'H') { 2.94 + home_httpd = xstrdup(after_colon); 2.95 +@@ -1531,6 +1541,13 @@ 2.96 + fd = open(url, O_RDONLY); 2.97 + } 2.98 + if (fd < 0) { 2.99 ++#if ENABLE_FEATURE_HTTPD_LISTING 2.100 ++ if (listing) { 2.101 ++ char args[BUF_SIZE]; 2.102 ++ snprintf(g_query = args, sizeof(args), "url=%s&home=%s", url, home_httpd); 2.103 ++ send_cgi_and_exit(listing, "GET", 0, NULL, NULL); 2.104 ++ } 2.105 ++#endif 2.106 + if (DEBUG) 2.107 + bb_perror_msg("can't open '%s'", url); 2.108 + /* Error pages are sent by using send_file_and_exit(SEND_BODY). 2.109 +
3.1 --- a/busybox/stuff/busybox-1.18.config Fri Apr 08 17:22:34 2011 +0200 3.2 +++ b/busybox/stuff/busybox-1.18.config Fri Apr 08 18:12:43 2011 +0200 3.3 @@ -1,7 +1,7 @@ 3.4 # 3.5 # Automatically generated make config: don't edit 3.6 -# Busybox version: 1.18.1 3.7 -# Tue Dec 21 16:26:23 2010 3.8 +# Busybox version: 1.18.4 3.9 +# Wed Apr 6 21:52:22 2011 3.10 # 3.11 CONFIG_HAVE_DOT_CONFIG=y 3.12 3.13 @@ -731,6 +731,7 @@ 3.14 CONFIG_FEATURE_HTTPD_BASIC_AUTH=y 3.15 CONFIG_FEATURE_HTTPD_AUTH_MD5=y 3.16 CONFIG_FEATURE_HTTPD_CGI=y 3.17 +CONFIG_FEATURE_HTTPD_LISTING=y 3.18 CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR=y 3.19 CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV=y 3.20 CONFIG_FEATURE_HTTPD_ENCODE_URL_STR=y