diff options
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/Documentation/NuttxPortingGuide.html | 5 | ||||
-rw-r--r-- | nuttx/configs/README.txt | 3 | ||||
-rw-r--r-- | nuttx/configs/eagle100/thttpd/defconfig | 4 | ||||
-rw-r--r-- | nuttx/examples/thttpd/main.c | 2 | ||||
-rw-r--r-- | nuttx/lib/lib_strcasecmp.c | 2 | ||||
-rw-r--r-- | nuttx/lib/lib_strncasecmp.c | 2 | ||||
-rw-r--r-- | nuttx/netutils/thttpd/config.h | 7 | ||||
-rw-r--r-- | nuttx/netutils/thttpd/libhttpd.c | 41 | ||||
-rw-r--r-- | nuttx/netutils/thttpd/libhttpd.h | 3 | ||||
-rw-r--r-- | nuttx/netutils/thttpd/thttpd.c | 22 |
10 files changed, 37 insertions, 54 deletions
diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html index ee91135ff..140c58386 100644 --- a/nuttx/Documentation/NuttxPortingGuide.html +++ b/nuttx/Documentation/NuttxPortingGuide.html @@ -2362,7 +2362,10 @@ extern void up_ledoff(int led); <code>CONFIG_THTTPD_SERVER_SOFTWARE</code>: SERVER_SOFTWARE: response </li> <li> - <code>CONFIG_THTTPD_CGI_PATH</code>: + <code>CONFIG_THTTPD_PATH</code>: Server working directory + </li> + <li> + <code>CONFIG_THTTPD_CGI_PATH</code>: Path to CGI executables </li> <li> <code>CONFIG_THTTPD_CGI_PATTERN</code>: Only CGI programs matching this diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt index c16e22a5c..9418f6ea8 100644 --- a/nuttx/configs/README.txt +++ b/nuttx/configs/README.txt @@ -358,7 +358,8 @@ defconfig -- This is a configuration file similar to the Linux CONFIG_THTTPD_IPADDR - Server IP address (no host name) CONFIG_THTTPD_SERVER_ADDRESS - SERVER_ADDRESS: response CONFIG_THTTPD_SERVER_SOFTWARE - SERVER_SOFTWARE: response - CONFIG_THTTPD_CGI_PATH - + CONFIG_THTTPD_PATH - Server working directory + CONFIG_THTTPD_CGI_PATH - Path to CGI executables CONFIG_THTTPD_CGI_PATTERN - Only CGI programs matching this pattern will be executed. In fact, if this value is not defined then no CGI logic will be built. diff --git a/nuttx/configs/eagle100/thttpd/defconfig b/nuttx/configs/eagle100/thttpd/defconfig index fc78a9dac..b369e70b0 100644 --- a/nuttx/configs/eagle100/thttpd/defconfig +++ b/nuttx/configs/eagle100/thttpd/defconfig @@ -483,7 +483,8 @@ CONFIG_NET_RESOLV_ENTRIES=4 # CONFIG_THTTPD_IPADDR - Server IP address (no host name) # CONFIG_THTTPD_SERVER_ADDRESS - SERVER_ADDRESS: response # CONFIG_THTTPD_SERVER_SOFTWARE - SERVER_SOFTWARE: response -# CONFIG_THTTPD_CGI_PATH - +# CONFIG_THTTPD_PATH - Server working directory +# CONFIG_THTTPD_CGI_PATH - Path to CGI executables # CONFIG_THTTPD_CGI_PATTERN - Only CGI programs matching this # pattern will be executed. In fact, if this value is not defined # then no CGI logic will be built. @@ -536,6 +537,7 @@ CONFIG_THTTPD_PORT=80 CONFIG_THTTPD_IPADDR=(10<<24|0<<16|0<<8|2) CONFIG_THTTPD_SERVER_ADDRESS="http://www.nuttx.org" CONFIG_THTTPD_SERVER_SOFTWARE="thttpd/2.25b 29dec2003-NuttX" +CONFIG_THTTPD_PATH="/mnt/www" CONFIG_THTTPD_CGI_PATH="/mnt/www/cgi-bin" CONFIG_THTTPD_CGI_PATTERN="/cgi-bin/*" CONFIG_THTTPD_CGI_PRIORITY=50 diff --git a/nuttx/examples/thttpd/main.c b/nuttx/examples/thttpd/main.c index 23c272565..b0f36b373 100644 --- a/nuttx/examples/thttpd/main.c +++ b/nuttx/examples/thttpd/main.c @@ -93,7 +93,7 @@ #define SECTORSIZE 512 #define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE) #define ROMFSDEV "/dev/ram0" -#define MOUNTPT "/mnt/www" +#define MOUNTPT CONFIG_THTTPD_PATH #ifdef CONFIG_CPP_HAVE_VARARGS # ifdef CONFIG_DEBUG diff --git a/nuttx/lib/lib_strcasecmp.c b/nuttx/lib/lib_strcasecmp.c index d9c5e5636..233cd3fc1 100644 --- a/nuttx/lib/lib_strcasecmp.c +++ b/nuttx/lib/lib_strcasecmp.c @@ -54,7 +54,7 @@ #ifndef CONFIG_ARCH_STRCMP int strcasecmp(const char *cs, const char *ct) { - register int result; + int result; for (;;) { if ((result = (int)toupper(*cs) - (int)toupper(*ct)) != 0 || !*cs) diff --git a/nuttx/lib/lib_strncasecmp.c b/nuttx/lib/lib_strncasecmp.c index c34396a50..fc8bf7b72 100644 --- a/nuttx/lib/lib_strncasecmp.c +++ b/nuttx/lib/lib_strncasecmp.c @@ -54,7 +54,7 @@ #ifndef CONFIG_ARCH_STRNCASECMP int strncasecmp(const char *cs, const char *ct, size_t nb) { - register int result = 0; + int result = 0; for (; nb > 0; nb--) { if ((result = (int)toupper(*cs) - (int)toupper(*ct)) != 0 || !*cs) diff --git a/nuttx/netutils/thttpd/config.h b/nuttx/netutils/thttpd/config.h index 2fe70539a..dce61a32d 100644 --- a/nuttx/netutils/thttpd/config.h +++ b/nuttx/netutils/thttpd/config.h @@ -88,6 +88,13 @@ # define CONFIG_THTTPD_SERVER_SOFTWARE "thttpd/2.25b 29dec2003-NuttX" # endif +# ifndef CONFIG_THTTPD_PATH +# ifdef CONFIG_CPP_HAVE_WARNING +# warning "CONFIG_THTTPD_PATH not defined" +# endif +# define CONFIG_THTTPD_PATH "/mnt/www" +# endif + # ifndef CONFIG_THTTPD_CGI_PATH # ifdef CONFIG_CPP_HAVE_WARNING # warning "CONFIG_THTTPD_CGI_PATH not defined" diff --git a/nuttx/netutils/thttpd/libhttpd.c b/nuttx/netutils/thttpd/libhttpd.c index 238f91076..60366ecfd 100644 --- a/nuttx/netutils/thttpd/libhttpd.c +++ b/nuttx/netutils/thttpd/libhttpd.c @@ -293,10 +293,6 @@ static void free_httpd_server(httpd_server * hs) free(hs->hostname); } - if (hs->cwd) - { - free(hs->cwd); - } free(hs); } } @@ -736,10 +732,14 @@ static int auth_check(httpd_conn *hc, char *dirname) #ifdef CONFIG_THTTPD_VHOST if (hc->hostdir[0] != '\0') - topdir = hc->hostdir; + { + topdir = hc->hostdir; + } else #endif - topdir = "."; + { + topdir = CONFIG_THTTPD_PATH; + } switch (auth_check2(hc, topdir)) { @@ -1418,7 +1418,7 @@ static char *expand_filename(char *path, char **restP, boolean tildemapped) *restP = r; if (checked[0] == '\0') { - (void)strcpy(checked, "."); + (void)strcpy(checked, CONFIG_THTTPD_PATH); } return checked; } @@ -1807,8 +1807,7 @@ static void ls_child(int argc, char **argv) strlen(hc->origfilename) + 1 + strlen(nameptrs[i])); - if (hc->expnfilename[0] == '\0' || - strcmp(hc->expnfilename, ".") == 0) + if (hc->expnfilename[0] == '\0' || strcmp(hc->expnfilename, ".") == 0) { (void)strcpy(name, nameptrs[i]); (void)strcpy(rname, nameptrs[i]); @@ -2109,11 +2108,11 @@ static void create_environment(httpd_conn *hc) (void)snprintf(buf, sizeof(buf), "/%s", hc->pathinfo); setenv("PATH_INFO", buf, TRUE); - l = strlen(hc->hs->cwd) + strlen(hc->pathinfo) + 1; + l = strlen(CONFIG_THTTPD_PATH) + strlen(hc->pathinfo) + 1; cp2 = NEW(char, l); if (cp2) { - (void)snprintf(cp2, l, "%s%s", hc->hs->cwd, hc->pathinfo); + (void)snprintf(cp2, l, "%s%s", CONFIG_THTTPD_PATH, hc->pathinfo); setenv("PATH_TRANSLATED", cp2, TRUE); } } @@ -3072,7 +3071,7 @@ static int really_start_request(httpd_conn *hc, struct timeval *nowP) cp = strrchr(dirname, '/'); if (!cp) { - (void)strcpy(dirname, "."); + (void)strcpy(dirname, CONFIG_THTTPD_PATH); } else { @@ -3381,12 +3380,10 @@ static size_t sockaddr_len(httpd_sockaddr *saP) * Public Functions ****************************************************************************/ -FAR httpd_server *httpd_initialize(FAR httpd_sockaddr *sa, FAR const char *cwd) +FAR httpd_server *httpd_initialize(FAR httpd_sockaddr *sa) { FAR httpd_server *hs; - nvdbg("cwd: %s\n", cwd); - /* Save the PID of the main thread */ main_thread = getpid(); @@ -3414,12 +3411,6 @@ FAR httpd_server *httpd_initialize(FAR httpd_sockaddr *sa, FAR const char *cwd) } hs->cgi_count = 0; - hs->cwd = strdup(cwd); - if (!hs->cwd) - { - ndbg("out of memory copying cwd\n"); - return (httpd_server *) 0; - } /* Initialize listen sockets */ @@ -3999,7 +3990,7 @@ int httpd_parse_request(httpd_conn *hc) } *url = '\0'; - if (strchr(reqhost, '/') != (char *)0 || reqhost[0] == '.') + if (strchr(reqhost, '/') != NULL || reqhost[0] == '.') { BADREQUEST("reqhost-2"); httpd_send_err(hc, 400, httpd_err400title, "", httpd_err400form, ""); @@ -4048,7 +4039,7 @@ int httpd_parse_request(httpd_conn *hc) if (hc->origfilename[0] == '\0') { - (void)strcpy(hc->origfilename, "."); + (void)strcpy(hc->origfilename, CONFIG_THTTPD_PATH); } /* Extract query string from encoded URL. */ @@ -4386,11 +4377,11 @@ int httpd_parse_request(httpd_conn *hc) if (hc->expnfilename[0] == '/') { - if (strncmp(hc->expnfilename, hc->hs->cwd, strlen(hc->hs->cwd)) == 0) + if (strncmp(hc->expnfilename, CONFIG_THTTPD_PATH, strlen(CONFIG_THTTPD_PATH)) == 0) { /* Elide the current directory. */ - (void)strcpy(hc->expnfilename, &hc->expnfilename[strlen(hc->hs->cwd)]); + (void)strcpy(hc->expnfilename, &hc->expnfilename[strlen(CONFIG_THTTPD_PATH)]); } #ifdef CONFIG_THTTPD_TILDE_MAP2 else if (hc->altdir[0] != '\0' && diff --git a/nuttx/netutils/thttpd/libhttpd.h b/nuttx/netutils/thttpd/libhttpd.h index 66410d343..a2f2e25f2 100644 --- a/nuttx/netutils/thttpd/libhttpd.h +++ b/nuttx/netutils/thttpd/libhttpd.h @@ -167,7 +167,6 @@ typedef struct { char *hostname; int cgi_count; - char *cwd; int listen_fd; } httpd_server; @@ -245,7 +244,7 @@ typedef struct * Return (httpd_server*) 0 on error. */ -extern FAR httpd_server *httpd_initialize(FAR httpd_sockaddr *sa, FAR const char *cwd); +extern FAR httpd_server *httpd_initialize(FAR httpd_sockaddr *sa); /* Call to unlisten/close socket(s) listening for new connections. */ diff --git a/nuttx/netutils/thttpd/thttpd.c b/nuttx/netutils/thttpd/thttpd.c index 093d89294..bf0f27de4 100644 --- a/nuttx/netutils/thttpd/thttpd.c +++ b/nuttx/netutils/thttpd/thttpd.c @@ -752,7 +752,6 @@ static void thttpd_logstats(long secs) int thttpd_main(int argc, char **argv) { - char cwd[MAXPATHLEN + 1]; int num_ready; int cnum; FAR struct connect_s *conn; @@ -775,25 +774,6 @@ int thttpd_main(int argc, char **argv) sa.sin_addr.s_addr = HTONL(CONFIG_THTTPD_IPADDR); #endif - /* Switch directories if requested */ - -#ifdef CONFIG_THTTPD_DIR - ret = chdir(CONFIG_THTTPD_DIR); - if (ret < 0) - { - ndbg("chdir: %d\n", errno); - exit(1); - } -#endif - - /* Get current directory */ - - (void)getcwd(cwd, sizeof(cwd) - 1); - if (cwd[strlen(cwd) - 1] != '/') - { - (void)strcat(cwd, "/"); - } - /* Initialize the fdwatch package to handle all of the configured * socket descriptors */ @@ -822,7 +802,7 @@ int thttpd_main(int argc, char **argv) /* Initialize the HTTP layer */ nvdbg("Calling httpd_initialize()\n"); - hs = httpd_initialize(&sa, cwd); + hs = httpd_initialize(&sa); if (!hs) { ndbg("httpd_initialize() failed\n"); |