1 Index: busybox-1.4.2/include/usage.h
2 ===================================================================
3 --- busybox-1.4.2.orig/include/usage.h 2007-06-04 13:21:32.103096256 +0200
4 +++ busybox-1.4.2/include/usage.h 2007-06-04 13:21:35.005655000 +0200
6 USE_FEATURE_HTTPD_BASIC_AUTH(" [-r <realm>]") \
7 USE_FEATURE_HTTPD_AUTH_MD5(" [-m pass]") \
10 + " [-d/-e <string>]" \
11 + " [-R <path> [-H <host>]]"
12 #define httpd_full_usage \
13 "Listen for incoming http server requests" \
16 " -m PASS Crypt PASS with md5 algorithm\n") \
17 " -h HOME Specifies http HOME directory (default ./)\n" \
18 " -e STRING HTML encode STRING\n" \
19 - " -d STRING URL decode STRING"
20 + " -d STRING URL decode STRING\n" \
21 + " -R PATH Redirect target path\n" \
22 + " -H HOST Redirect target host"
24 #define hwclock_trivial_usage \
25 "[-r|--show] [-s|--hctosys] [-w|--systohc] [-l|--localtime] [-u|--utc]"
26 Index: busybox-1.4.2/networking/httpd.c
27 ===================================================================
28 --- busybox-1.4.2.orig/networking/httpd.c 2007-06-04 13:21:34.588718384 +0200
29 +++ busybox-1.4.2/networking/httpd.c 2007-06-04 13:21:35.006654848 +0200
31 USE_FEATURE_HTTPD_CGI(char *user_agent;)
33 const char *configFile;
34 + const char *redirectPath;
35 + const char *redirectHost;
38 #if ENABLE_FEATURE_HTTPD_CGI || DEBUG
42 if (responseNum == HTTP_MOVED_TEMPORARILY) {
43 - len += sprintf(buf+len, "Location: %s/%s%s\r\n",
44 + len += sprintf(buf+len, "Location: %s%s%s%s%s%s\r\n",
45 + (config->redirectHost ? "http://" : ""),
46 + (config->redirectHost ? config->redirectHost : ""),
47 config->found_moved_temporarily,
48 + (config->redirectHost ? "" : "/"),
49 (config->query ? "?" : ""),
50 (config->query ? config->query : ""));
52 @@ -1594,8 +1599,12 @@
53 *++purl = '\0'; /* so keep last character */
54 test = purl; /* end ptr */
56 + /* redirect active */
57 + if (config->redirectPath && (strncmp(url, config->redirectPath, strlen(config->redirectPath)) != 0))
58 + config->found_moved_temporarily = config->redirectPath;
60 /* If URL is directory, adding '/' */
61 - if (test[-1] != '/') {
62 + if(!config->redirectPath && (test[-1] != '/')) {
63 if (is_directory(url + 1, 1, &sb)) {
64 config->found_moved_temporarily = url;
70 - c_opt_config_file = 0,
71 + R_opt_redirect_path = 0,
72 + H_opt_redirect_host,
76 USE_FEATURE_HTTPD_ENCODE_URL_STR(e_opt_encode_url,)
78 OPT_FOREGROUND = 1 << p_opt_foreground,
81 -static const char httpd_opts[] = "c:d:h:"
82 +static const char httpd_opts[] = "R:H:c:d:h:"
83 USE_FEATURE_HTTPD_ENCODE_URL_STR("e:")
84 USE_FEATURE_HTTPD_BASIC_AUTH("r:")
85 USE_FEATURE_HTTPD_AUTH_MD5("m:")
87 config->ContentLength = -1;
89 opt = getopt32(argc, argv, httpd_opts,
90 + &(config->redirectPath), &(config->redirectHost),
91 &(config->configFile), &url_for_decode, &home_httpd
92 USE_FEATURE_HTTPD_ENCODE_URL_STR(, &url_for_encode)
93 USE_FEATURE_HTTPD_BASIC_AUTH(, &(config->realm))