wok-6.x rev 9552

busybox/httpd: no patch need for directory list
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Apr 10 13:13:17 2011 +0200 (2011-04-10)
parents 04815ab9b79d
children befd46df350e
files busybox/receipt busybox/stuff/busybox-1.18-httpd.u
line diff
     1.1 --- a/busybox/receipt	Sun Apr 10 12:08:35 2011 +0000
     1.2 +++ b/busybox/receipt	Sun Apr 10 13:13:17 2011 +0200
     1.3 @@ -28,7 +28,6 @@
     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 --- a/busybox/stuff/busybox-1.18-httpd.u	Sun Apr 10 12:08:35 2011 +0000
     2.2 +++ b/busybox/stuff/busybox-1.18-httpd.u	Sun Apr 10 13:13:17 2011 +0200
     2.3 @@ -1,18 +1,15 @@
     2.4 -This patch allows to run a script to list the directory with httpd
     2.5 +Httpd already support directory listing:
     2.6  
     2.7 -Install /etc/httpd.conf, /var/www/cgi-bin/list.sh and try !
     2.8 +Install /etc/httpd.conf, /var/www/cgi-bin/index.cgi and try !
     2.9  
    2.10  ===>8=== /etc/httpd.conf ===>8===
    2.11  H:/var/www
    2.12 -*.sh:/bin/sh
    2.13 -L:/cgi-bin/list.sh
    2.14 -===>8=== /var/www/cgi-bin/list.sh ===>8===
    2.15 +===>8=== /var/www/cgi-bin/index.cgi ===>8===
    2.16  #!/bin/sh
    2.17  
    2.18 -eval ${QUERY_STRING/&/;}
    2.19 -path=$(dirname /$url)
    2.20 +path=$QUERY_STRING
    2.21  
    2.22 -unix2dos <<EOT
    2.23 +cat <<EOT  
    2.24  Content-type: text/html
    2.25  
    2.26  <!DOCTYPE html>
    2.27 @@ -23,84 +20,9 @@
    2.28  <body>
    2.29  	<h1>Index of $path</h1>
    2.30  	<ul>
    2.31 -$(cd $home$path && { [ "$path" != "/" ] && echo "../" ; ls -p; } | \
    2.32 +$(cd ${PWD/?index.cgi/}$path && { [ "$path" != "/" ] && echo "../"; ls -p; } | \
    2.33    sed 's|.*|		<li><a href="&">&</a></li>|')
    2.34  	</ul>
    2.35  </body>
    2.36  </html>
    2.37  EOT
    2.38 -===>8======>8======>8======>8======>8===
    2.39 -
    2.40 ---- busybox-1.18.4/networking/Config.src
    2.41 -+++ busybox-1.18.4/networking/Config.src
    2.42 -@@ -216,6 +216,14 @@
    2.43 - 	  This option allows scripts and executables to be invoked
    2.44 - 	  when specific URLs are requested.
    2.45 - 
    2.46 -+config FEATURE_HTTPD_LISTING
    2.47 -+	bool "Support for directory listing through a CGI script"
    2.48 -+	default y
    2.49 -+	depends on FEATURE_HTTPD_CGI
    2.50 -+	help
    2.51 -+	  This option allows to run a script to list the directory
    2.52 -+	  content.
    2.53 -+
    2.54 - config FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
    2.55 - 	bool "Support for running scripts through an interpreter"
    2.56 - 	default y
    2.57 -
    2.58 ---- busybox-1.18.4/networking/httpd.c
    2.59 -+++ busybox-1.18.4/networking/httpd.c
    2.60 -@@ -42,6 +42,7 @@
    2.61 -  * D:*               # Deny from other IP connections
    2.62 -  * E404:/path/e404.html # /path/e404.html is the 404 (not found) error page
    2.63 -  * I:index.html      # Show index.html when a directory is requested
    2.64 -+ * L:/path/list      # List directory file from $url and $home arguments
    2.65 -  *
    2.66 -  * P:/url:[http://]hostname[:port]/new/path
    2.67 -  *                   # When /urlXXXXXX is requested, reverse proxy
    2.68 -@@ -240,6 +241,7 @@
    2.69 - 	const char *opt_c_configFile;
    2.70 - 	const char *home_httpd;
    2.71 - 	const char *index_page;
    2.72 -+	const char *listing;
    2.73 - 
    2.74 - 	const char *found_mime_type;
    2.75 - 	const char *found_moved_temporarily;
    2.76 -@@ -291,6 +293,7 @@
    2.77 - #define opt_c_configFile  (G.opt_c_configFile )
    2.78 - #define home_httpd        (G.home_httpd       )
    2.79 - #define index_page        (G.index_page       )
    2.80 -+#define listing           (G.listing          )
    2.81 - #define found_mime_type   (G.found_mime_type  )
    2.82 - #define found_moved_temporarily (G.found_moved_temporarily)
    2.83 - #define last_mod          (G.last_mod         )
    2.84 -@@ -579,6 +582,13 @@
    2.85 - 			continue;
    2.86 - 		}
    2.87 - 
    2.88 -+#if ENABLE_FEATURE_HTTPD_LISTING
    2.89 -+		if (flag == FIRST_PARSE && ch == 'L') {
    2.90 -+			listing = xstrdup(after_colon);
    2.91 -+			continue;
    2.92 -+		}
    2.93 -+#endif
    2.94 -+
    2.95 - 		/* do not allow jumping around using H in subdir's configs */
    2.96 - 		if (flag == FIRST_PARSE && ch == 'H') {
    2.97 - 			home_httpd = xstrdup(after_colon);
    2.98 -@@ -1531,6 +1541,13 @@
    2.99 - 		fd = open(url, O_RDONLY);
   2.100 - 	}
   2.101 - 	if (fd < 0) {
   2.102 -+#if ENABLE_FEATURE_HTTPD_LISTING
   2.103 -+		if (listing) {
   2.104 -+			char args[BUF_SIZE];
   2.105 -+			snprintf(g_query = args, sizeof(args), "url=%s&home=%s", url, home_httpd);
   2.106 -+			send_cgi_and_exit(listing, "GET", 0, NULL, NULL);
   2.107 -+		}
   2.108 -+#endif
   2.109 - 		if (DEBUG)
   2.110 - 			bb_perror_msg("can't open '%s'", url);
   2.111 - 		/* Error pages are sent by using send_file_and_exit(SEND_BODY).
   2.112 -