clean up the directory layout of the uci shell api
[openwrt.git] / package / busybox / patches / 350-httpd_redir.patch
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
5 @@ -1418,7 +1418,8 @@
6 USE_FEATURE_HTTPD_BASIC_AUTH(" [-r realm]") \
7 USE_FEATURE_HTTPD_AUTH_MD5(" [-m pass]") \
8 " [-h home]" \
9 - " [-d/-e string]"
10 + " [-d/-e string]" \
11 + " [-R <path> [-H <host>]]"
12 #define httpd_full_usage \
13 "Listen for incoming HTTP requests" \
14 "\n\nOptions:" \
15 @@ -1436,6 +1437,8 @@
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" \
21
22 #define hwclock_trivial_usage \
23 USE_GETOPT_LONG( \
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
28 @@ -253,6 +253,8 @@
29
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 */
35
36 USE_FEATURE_HTTPD_BASIC_AUTH(const char *g_realm;)
37 @@ -297,6 +299,8 @@
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 )
46 @@ -988,8 +992,11 @@
47 }
48 #endif
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 ? "" : "/"),
56 (g_query ? "?" : ""),
57 (g_query ? g_query : ""));
58 }
59 @@ -1907,8 +1914,12 @@
60 *++urlp = '\0'; /* so keep last character */
61 tptr = urlp; /* end ptr */
62
63 + /* redirect active */
64 + if (redirect_path && (strncmp(urlcopy, redirect_path, strlen(redirect_path)) != 0))
65 + found_moved_temporarily = redirect_path;
66 +
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;
72 }
73 @@ -2252,7 +2263,9 @@
74 #endif
75
76 enum {
77 - c_opt_config_file = 0,
78 + R_opt_redirect_path = 0,
79 + H_opt_redirect_host,
80 + c_opt_config_file,
81 d_opt_decode_url,
82 h_opt_home_httpd,
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
87 * relative too. */
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:")
94 "p:ifv",
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)
This page took 0.048742 seconds and 5 git commands to generate.