1 Index: busybox-1.8.1/include/usage.h
2 ===================================================================
3 --- busybox-1.8.1.orig/include/usage.h 2007-11-10 16:54:16.433376848 +0100
4 +++ busybox-1.8.1/include/usage.h 2007-11-10 16:54:29.970148260 +0100
6 USE_FEATURE_HTTPD_BASIC_AUTH(" [-r realm]") \
7 USE_FEATURE_HTTPD_AUTH_MD5(" [-m pass]") \
11 + " [-R <path> [-H <host>]]"
12 #define httpd_full_usage \
13 "Listen for incoming HTTP requests" \
16 "\n -h HOME Home directory (default .)" \
17 "\n -e STRING HTML encode STRING" \
18 "\n -d STRING URL decode STRING" \
19 + "\n -R PATH Redirect target path" \
20 + "\n -H HOST Redirect target host" \
22 #define hwclock_trivial_usage \
24 Index: busybox-1.8.1/networking/httpd.c
25 ===================================================================
26 --- busybox-1.8.1.orig/networking/httpd.c 2007-11-10 16:54:28.346055711 +0100
27 +++ busybox-1.8.1/networking/httpd.c 2007-11-10 16:54:56.639668071 +0100
30 const char *found_mime_type;
31 const char *found_moved_temporarily;
32 + const char *redirect_path;
33 + const char *redirect_host;
34 Htaccess_IP *ip_a_d; /* config allow/deny lines */
36 USE_FEATURE_HTTPD_BASIC_AUTH(const char *g_realm;)
38 #define home_httpd (G.home_httpd )
39 #define found_mime_type (G.found_mime_type )
40 #define found_moved_temporarily (G.found_moved_temporarily)
41 +#define redirect_path (G.redirect_path )
42 +#define redirect_host (G.redirect_host )
43 #define last_mod (G.last_mod )
44 #define ip_a_d (G.ip_a_d )
45 #define g_realm (G.g_realm )
49 if (responseNum == HTTP_MOVED_TEMPORARILY) {
50 - len += sprintf(iobuf + len, "Location: %s/%s%s\r\n",
51 + len += sprintf(iobuf + len, "Location: %s%s%s%s%s%s\r\n",
52 + (redirect_host ? "http://" : ""),
53 + (redirect_host ? redirect_host : ""),
54 found_moved_temporarily,
55 + (redirect_host ? "" : "/"),
57 (g_query ? g_query : ""));
59 @@ -1907,8 +1914,12 @@
60 *++urlp = '\0'; /* so keep last character */
61 tptr = urlp; /* end ptr */
63 + /* redirect active */
64 + if (redirect_path && (strncmp(urlcopy, redirect_path, strlen(redirect_path)) != 0))
65 + found_moved_temporarily = redirect_path;
67 /* If URL is a directory, add '/' */
68 - if (tptr[-1] != '/') {
69 + if (!redirect_path && (tptr[-1] != '/')) {
70 if (is_directory(urlcopy + 1, 1, &sb)) {
71 found_moved_temporarily = urlcopy;
77 - c_opt_config_file = 0,
78 + R_opt_redirect_path = 0,
79 + H_opt_redirect_host,
83 USE_FEATURE_HTTPD_ENCODE_URL_STR(e_opt_encode_url,)
84 @@ -2301,12 +2314,13 @@
85 /* We do not "absolutize" path given by -h (home) opt.
86 * If user gives relative path in -h, $SCRIPT_FILENAME can end up
88 - opt = getopt32(argv, "c:d:h:"
89 + opt = getopt32(argv, "R:H:c:d:h:"
90 USE_FEATURE_HTTPD_ENCODE_URL_STR("e:")
91 USE_FEATURE_HTTPD_BASIC_AUTH("r:")
92 USE_FEATURE_HTTPD_AUTH_MD5("m:")
93 USE_FEATURE_HTTPD_SETUID("u:")
95 + &redirect_path, &redirect_host,
96 &configFile, &url_for_decode, &home_httpd
97 USE_FEATURE_HTTPD_ENCODE_URL_STR(, &url_for_encode)
98 USE_FEATURE_HTTPD_BASIC_AUTH(, &g_realm)