# HG changeset patch # User Pascal Bellard # Date 1302279163 -7200 # Node ID 3dc7c4a7f5efc4003bc10cab6aa71dfdf5c954b0 # Parent a5912cbfcc85581fa1c071cd2a501f5cc3536922 busybox/httpd: add directory list support diff -r a5912cbfcc85 -r 3dc7c4a7f5ef busybox/receipt --- a/busybox/receipt Fri Apr 08 17:22:34 2011 +0200 +++ b/busybox/receipt Fri Apr 08 18:12:43 2011 +0200 @@ -28,6 +28,7 @@ printable.u cmdline.u conspy.u +httpd.u EOT cp $stuff/$PACKAGE-${VERSION%.*}.config .config } diff -r a5912cbfcc85 -r 3dc7c4a7f5ef busybox/stuff/busybox-1.18-httpd.u --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/busybox/stuff/busybox-1.18-httpd.u Fri Apr 08 18:12:43 2011 +0200 @@ -0,0 +1,106 @@ +This patch allows to run a script to list the directory with httpd + +Install /etc/httpd.conf, /var/www/cgi-bin/list.sh and try ! + +===>8=== /etc/httpd.conf ===>8=== +H:/var/www +*.sh:/bin/sh +L:/cgi-bin/list.sh +===>8=== /var/www/cgi-bin/list.sh ===>8=== +#!/bin/sh + +eval ${QUERY_STRING/&/;} +path=$(dirname /$url) + +unix2dos < + + + Index of $path + + +

Index of $path

+ + + +EOT +===>8======>8======>8======>8======>8=== + +--- busybox-1.18.4/networking/Config.src ++++ busybox-1.18.4/networking/Config.src +@@ -216,6 +216,14 @@ + This option allows scripts and executables to be invoked + when specific URLs are requested. + ++config FEATURE_HTTPD_LISTING ++ bool "Support for directory listing through a CGI script" ++ default y ++ depends on FEATURE_HTTPD_CGI ++ help ++ This option allows to run a script to list the directory ++ content. ++ + config FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR + bool "Support for running scripts through an interpreter" + default y + +--- busybox-1.18.4/networking/httpd.c ++++ busybox-1.18.4/networking/httpd.c +@@ -42,6 +42,7 @@ + * D:* # Deny from other IP connections + * E404:/path/e404.html # /path/e404.html is the 404 (not found) error page + * I:index.html # Show index.html when a directory is requested ++ * L:/path/list # List directory file from $url and $home arguments + * + * P:/url:[http://]hostname[:port]/new/path + * # When /urlXXXXXX is requested, reverse proxy +@@ -240,6 +241,7 @@ + const char *opt_c_configFile; + const char *home_httpd; + const char *index_page; ++ const char *listing; + + const char *found_mime_type; + const char *found_moved_temporarily; +@@ -291,6 +293,7 @@ + #define opt_c_configFile (G.opt_c_configFile ) + #define home_httpd (G.home_httpd ) + #define index_page (G.index_page ) ++#define listing (G.listing ) + #define found_mime_type (G.found_mime_type ) + #define found_moved_temporarily (G.found_moved_temporarily) + #define last_mod (G.last_mod ) +@@ -579,6 +582,13 @@ + continue; + } + ++#if ENABLE_FEATURE_HTTPD_LISTING ++ if (flag == FIRST_PARSE && ch == 'L') { ++ listing = xstrdup(after_colon); ++ continue; ++ } ++#endif ++ + /* do not allow jumping around using H in subdir's configs */ + if (flag == FIRST_PARSE && ch == 'H') { + home_httpd = xstrdup(after_colon); +@@ -1531,6 +1541,13 @@ + fd = open(url, O_RDONLY); + } + if (fd < 0) { ++#if ENABLE_FEATURE_HTTPD_LISTING ++ if (listing) { ++ char args[BUF_SIZE]; ++ snprintf(g_query = args, sizeof(args), "url=%s&home=%s", url, home_httpd); ++ send_cgi_and_exit(listing, "GET", 0, NULL, NULL); ++ } ++#endif + if (DEBUG) + bb_perror_msg("can't open '%s'", url); + /* Error pages are sent by using send_file_and_exit(SEND_BODY). + diff -r a5912cbfcc85 -r 3dc7c4a7f5ef busybox/stuff/busybox-1.18.config --- a/busybox/stuff/busybox-1.18.config Fri Apr 08 17:22:34 2011 +0200 +++ b/busybox/stuff/busybox-1.18.config Fri Apr 08 18:12:43 2011 +0200 @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit -# Busybox version: 1.18.1 -# Tue Dec 21 16:26:23 2010 +# Busybox version: 1.18.4 +# Wed Apr 6 21:52:22 2011 # CONFIG_HAVE_DOT_CONFIG=y @@ -731,6 +731,7 @@ CONFIG_FEATURE_HTTPD_BASIC_AUTH=y CONFIG_FEATURE_HTTPD_AUTH_MD5=y CONFIG_FEATURE_HTTPD_CGI=y +CONFIG_FEATURE_HTTPD_LISTING=y CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR=y CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV=y CONFIG_FEATURE_HTTPD_ENCODE_URL_STR=y