fix the issue of httpd no longer working when its root directory is replaced
[openwrt.git] / package / busybox / patches / 440-httpd_chdir.patch
1 diff -ur busybox.old/networking/httpd.c busybox.dev/networking/httpd.c
2 --- busybox.old/networking/httpd.c      2007-02-27 23:15:20.611300000 +0100
3 +++ busybox.dev/networking/httpd.c      2007-02-27 23:18:10.022546112 +0100
4 @@ -102,6 +102,7 @@
5  static const char default_path_httpd_conf[] = "/etc";
6  static const char httpd_conf[] = "httpd.conf";
7  static const char home[] = "./";
8 +static const char *home_httpd = home;
9  
10  #define TIMEOUT 60
11  
12 @@ -1500,6 +1501,8 @@
13  #if ENABLE_FEATURE_HTTPD_BASIC_AUTH
14         int credentials = -1;  /* if not required this is Ok */
15  #endif
16 +       
17 +       xchdir(home_httpd);
18  
19         sa.sa_handler = handle_sigalrm;
20         sigemptyset(&sa.sa_mask);
21 @@ -1931,7 +1934,6 @@
22  int httpd_main(int argc, char *argv[])
23  {
24         unsigned opt;
25 -       const char *home_httpd = home;
26         char *url_for_decode;
27         USE_FEATURE_HTTPD_ENCODE_URL_STR(const char *url_for_encode;)
28         const char *s_port;