httpd:
Kill config options by making them always on: FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES This makes httpd.c remotely readable - it had ~125 #ifdefs, now it has ~100. The growth on a .config with all FEATURE_HTTPDs off is: function old new delta send_file_and_exit - 269 +269 parse_conf 683 763 +80 free_llist - 32 +32 httpd_main 427 454 +27 sighup_handler - 15 +15 handle_incoming_and_exit 1110 905 -205 ------------------------------------------------------------------------------ (add/remove: 3/0 grow/shrink: 2/1 up/down: 423/-205) Total: 218 bytes
This commit is contained in:
parent
6d5590f9d0
commit
1cbfd98ded
@ -630,11 +630,9 @@ CONFIG_HOSTNAME=y
|
|||||||
CONFIG_HTTPD=y
|
CONFIG_HTTPD=y
|
||||||
CONFIG_FEATURE_HTTPD_RANGES=y
|
CONFIG_FEATURE_HTTPD_RANGES=y
|
||||||
CONFIG_FEATURE_HTTPD_USE_SENDFILE=y
|
CONFIG_FEATURE_HTTPD_USE_SENDFILE=y
|
||||||
CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP=y
|
|
||||||
CONFIG_FEATURE_HTTPD_SETUID=y
|
CONFIG_FEATURE_HTTPD_SETUID=y
|
||||||
CONFIG_FEATURE_HTTPD_BASIC_AUTH=y
|
CONFIG_FEATURE_HTTPD_BASIC_AUTH=y
|
||||||
CONFIG_FEATURE_HTTPD_AUTH_MD5=y
|
CONFIG_FEATURE_HTTPD_AUTH_MD5=y
|
||||||
CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES=y
|
|
||||||
CONFIG_FEATURE_HTTPD_CGI=y
|
CONFIG_FEATURE_HTTPD_CGI=y
|
||||||
CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR=y
|
CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR=y
|
||||||
CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV=y
|
CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV=y
|
||||||
|
@ -141,14 +141,6 @@ config FEATURE_HTTPD_USE_SENDFILE
|
|||||||
When enabled, httpd will use the kernel sendfile() function
|
When enabled, httpd will use the kernel sendfile() function
|
||||||
instead of read/write loop.
|
instead of read/write loop.
|
||||||
|
|
||||||
config FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP
|
|
||||||
bool "Support reloading of global config file on HUP signal"
|
|
||||||
default n
|
|
||||||
depends on HTTPD
|
|
||||||
help
|
|
||||||
This option enables processing of SIGHUP to reload cached
|
|
||||||
configuration settings.
|
|
||||||
|
|
||||||
config FEATURE_HTTPD_SETUID
|
config FEATURE_HTTPD_SETUID
|
||||||
bool "Enable -u <user> option"
|
bool "Enable -u <user> option"
|
||||||
default n
|
default n
|
||||||
@ -175,14 +167,6 @@ config FEATURE_HTTPD_AUTH_MD5
|
|||||||
Enables basic per URL authentication from /etc/httpd.conf
|
Enables basic per URL authentication from /etc/httpd.conf
|
||||||
using md5 passwords.
|
using md5 passwords.
|
||||||
|
|
||||||
config FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES
|
|
||||||
bool "Support loading additional MIME types at run-time"
|
|
||||||
default n
|
|
||||||
depends on HTTPD
|
|
||||||
help
|
|
||||||
This option enables support for additional MIME types at
|
|
||||||
run-time to be specified in the configuration file.
|
|
||||||
|
|
||||||
config FEATURE_HTTPD_CGI
|
config FEATURE_HTTPD_CGI
|
||||||
bool "Support Common Gateway Interface (CGI)"
|
bool "Support Common Gateway Interface (CGI)"
|
||||||
default y
|
default y
|
||||||
|
@ -97,7 +97,7 @@
|
|||||||
|
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
#if ENABLE_FEATURE_HTTPD_USE_SENDFILE
|
#if ENABLE_FEATURE_HTTPD_USE_SENDFILE
|
||||||
#include <sys/sendfile.h>
|
# include <sys/sendfile.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define DEBUG 1
|
//#define DEBUG 1
|
||||||
@ -268,9 +268,7 @@ struct globals {
|
|||||||
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH
|
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH
|
||||||
Htaccess *g_auth; /* config user:password lines */
|
Htaccess *g_auth; /* config user:password lines */
|
||||||
#endif
|
#endif
|
||||||
#if ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES
|
|
||||||
Htaccess *mime_a; /* config mime types */
|
Htaccess *mime_a; /* config mime types */
|
||||||
#endif
|
|
||||||
#if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
|
#if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
|
||||||
Htaccess *script_i; /* config script interpreters */
|
Htaccess *script_i; /* config script interpreters */
|
||||||
#endif
|
#endif
|
||||||
@ -310,6 +308,12 @@ struct globals {
|
|||||||
#define range_start (G.range_start )
|
#define range_start (G.range_start )
|
||||||
#define range_end (G.range_end )
|
#define range_end (G.range_end )
|
||||||
#define range_len (G.range_len )
|
#define range_len (G.range_len )
|
||||||
|
#else
|
||||||
|
enum {
|
||||||
|
range_start = 0,
|
||||||
|
range_end = MAXINT(off_t) - 1,
|
||||||
|
range_len = MAXINT(off_t),
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
#define rmt_ip_str (G.rmt_ip_str )
|
#define rmt_ip_str (G.rmt_ip_str )
|
||||||
#define g_auth (G.g_auth )
|
#define g_auth (G.g_auth )
|
||||||
@ -328,14 +332,6 @@ struct globals {
|
|||||||
file_size = -1; \
|
file_size = -1; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#if !ENABLE_FEATURE_HTTPD_RANGES
|
|
||||||
enum {
|
|
||||||
range_start = 0,
|
|
||||||
range_end = MAXINT(off_t) - 1,
|
|
||||||
range_len = MAXINT(off_t),
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#define STRNCASECMP(a, str) strncasecmp((a), (str), sizeof(str)-1)
|
#define STRNCASECMP(a, str) strncasecmp((a), (str), sizeof(str)-1)
|
||||||
|
|
||||||
@ -358,14 +354,10 @@ static void free_llist(has_next_ptr **pptr)
|
|||||||
*pptr = NULL;
|
*pptr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH \
|
|
||||||
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \
|
|
||||||
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
|
|
||||||
static ALWAYS_INLINE void free_Htaccess_list(Htaccess **pptr)
|
static ALWAYS_INLINE void free_Htaccess_list(Htaccess **pptr)
|
||||||
{
|
{
|
||||||
free_llist((has_next_ptr**)pptr);
|
free_llist((has_next_ptr**)pptr);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static ALWAYS_INLINE void free_Htaccess_IP_list(Htaccess_IP **pptr)
|
static ALWAYS_INLINE void free_Htaccess_IP_list(Htaccess_IP **pptr)
|
||||||
{
|
{
|
||||||
@ -488,11 +480,7 @@ static void parse_conf(const char *path, int flag)
|
|||||||
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH
|
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH
|
||||||
Htaccess *prev;
|
Htaccess *prev;
|
||||||
#endif
|
#endif
|
||||||
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH \
|
|
||||||
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \
|
|
||||||
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
|
|
||||||
Htaccess *cur;
|
Htaccess *cur;
|
||||||
#endif
|
|
||||||
const char *filename = configFile;
|
const char *filename = configFile;
|
||||||
char buf[160];
|
char buf[160];
|
||||||
char *p, *p0;
|
char *p, *p0;
|
||||||
@ -502,22 +490,16 @@ static void parse_conf(const char *path, int flag)
|
|||||||
/* discard old rules */
|
/* discard old rules */
|
||||||
free_Htaccess_IP_list(&ip_a_d);
|
free_Htaccess_IP_list(&ip_a_d);
|
||||||
flg_deny_all = 0;
|
flg_deny_all = 0;
|
||||||
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH \
|
|
||||||
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \
|
|
||||||
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
|
|
||||||
/* retain previous auth and mime config only for subdir parse */
|
/* retain previous auth and mime config only for subdir parse */
|
||||||
if (flag != SUBDIR_PARSE) {
|
if (flag != SUBDIR_PARSE) {
|
||||||
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH
|
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH
|
||||||
free_Htaccess_list(&g_auth);
|
free_Htaccess_list(&g_auth);
|
||||||
#endif
|
#endif
|
||||||
#if ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES
|
|
||||||
free_Htaccess_list(&mime_a);
|
free_Htaccess_list(&mime_a);
|
||||||
#endif
|
|
||||||
#if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
|
#if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
|
||||||
free_Htaccess_list(&script_i);
|
free_Htaccess_list(&script_i);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (flag == SUBDIR_PARSE || filename == NULL) {
|
if (flag == SUBDIR_PARSE || filename == NULL) {
|
||||||
filename = alloca(strlen(path) + sizeof(httpd_conf) + 2);
|
filename = alloca(strlen(path) + sizeof(httpd_conf) + 2);
|
||||||
@ -701,9 +683,6 @@ static void parse_conf(const char *path, int flag)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH \
|
|
||||||
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \
|
|
||||||
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
|
|
||||||
/* storing current config line */
|
/* storing current config line */
|
||||||
cur = xzalloc(sizeof(Htaccess) + strlen(p0));
|
cur = xzalloc(sizeof(Htaccess) + strlen(p0));
|
||||||
strcpy(cur->before_colon, p0);
|
strcpy(cur->before_colon, p0);
|
||||||
@ -713,14 +692,12 @@ static void parse_conf(const char *path, int flag)
|
|||||||
#endif
|
#endif
|
||||||
cur->after_colon = strchr(cur->before_colon, ':');
|
cur->after_colon = strchr(cur->before_colon, ':');
|
||||||
*cur->after_colon++ = '\0';
|
*cur->after_colon++ = '\0';
|
||||||
#if ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES
|
|
||||||
if (cur->before_colon[0] == '.') {
|
if (cur->before_colon[0] == '.') {
|
||||||
/* .mime line: prepend to mime_a list */
|
/* .mime line: prepend to mime_a list */
|
||||||
cur->next = mime_a;
|
cur->next = mime_a;
|
||||||
mime_a = cur;
|
mime_a = cur;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
|
#if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
|
||||||
if (cur->before_colon[0] == '*' && cur->before_colon[1] == '.') {
|
if (cur->before_colon[0] == '*' && cur->before_colon[1] == '.') {
|
||||||
/* script interpreter line: prepend to script_i list */
|
/* script interpreter line: prepend to script_i list */
|
||||||
@ -762,7 +739,6 @@ static void parse_conf(const char *path, int flag)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* BASIC_AUTH */
|
#endif /* BASIC_AUTH */
|
||||||
#endif /* BASIC_AUTH || MIME_TYPES || SCRIPT_INTERPR */
|
|
||||||
} /* while (fgets) */
|
} /* while (fgets) */
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
@ -1507,7 +1483,7 @@ static void send_cgi_and_exit(
|
|||||||
* const char *url The requested URL (with leading /).
|
* const char *url The requested URL (with leading /).
|
||||||
* what What to send (headers/body/both).
|
* what What to send (headers/body/both).
|
||||||
*/
|
*/
|
||||||
static void send_file_and_exit(const char *url, int what)
|
static NOINLINE void send_file_and_exit(const char *url, int what)
|
||||||
{
|
{
|
||||||
static const char *const suffixTable[] = {
|
static const char *const suffixTable[] = {
|
||||||
/* Warning: shorter equivalent suffix in one line must be first */
|
/* Warning: shorter equivalent suffix in one line must be first */
|
||||||
@ -1532,13 +1508,26 @@ static void send_file_and_exit(const char *url, int what)
|
|||||||
};
|
};
|
||||||
|
|
||||||
char *suffix;
|
char *suffix;
|
||||||
int f;
|
int fd;
|
||||||
const char *const *table;
|
const char *const *table;
|
||||||
const char *try_suffix;
|
const char *try_suffix;
|
||||||
ssize_t count;
|
ssize_t count;
|
||||||
#if ENABLE_FEATURE_HTTPD_USE_SENDFILE
|
|
||||||
off_t offset;
|
fd = open(url, O_RDONLY);
|
||||||
#endif
|
if (fd < 0) {
|
||||||
|
if (DEBUG)
|
||||||
|
bb_perror_msg("can't open '%s'", url);
|
||||||
|
/* Error pages are sent by using send_file_and_exit(SEND_BODY).
|
||||||
|
* IOW: it is unsafe to call send_headers_and_exit
|
||||||
|
* if what is SEND_BODY! Can recurse! */
|
||||||
|
if (what != SEND_BODY)
|
||||||
|
send_headers_and_exit(HTTP_NOT_FOUND);
|
||||||
|
log_and_exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
bb_error_msg("sending file '%s' content-type: %s",
|
||||||
|
url, found_mime_type);
|
||||||
|
|
||||||
/* If you want to know about EPIPE below
|
/* If you want to know about EPIPE below
|
||||||
* (happens if you abort downloads from local httpd): */
|
* (happens if you abort downloads from local httpd): */
|
||||||
@ -1549,9 +1538,7 @@ static void send_file_and_exit(const char *url, int what)
|
|||||||
/* If not found, set default as "application/octet-stream"; */
|
/* If not found, set default as "application/octet-stream"; */
|
||||||
found_mime_type = "application/octet-stream";
|
found_mime_type = "application/octet-stream";
|
||||||
if (suffix) {
|
if (suffix) {
|
||||||
#if ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES
|
|
||||||
Htaccess *cur;
|
Htaccess *cur;
|
||||||
#endif
|
|
||||||
for (table = suffixTable; *table; table += 2) {
|
for (table = suffixTable; *table; table += 2) {
|
||||||
try_suffix = strstr(table[0], suffix);
|
try_suffix = strstr(table[0], suffix);
|
||||||
if (try_suffix) {
|
if (try_suffix) {
|
||||||
@ -1562,30 +1549,12 @@ static void send_file_and_exit(const char *url, int what)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES
|
|
||||||
for (cur = mime_a; cur; cur = cur->next) {
|
for (cur = mime_a; cur; cur = cur->next) {
|
||||||
if (strcmp(cur->before_colon, suffix) == 0) {
|
if (strcmp(cur->before_colon, suffix) == 0) {
|
||||||
found_mime_type = cur->after_colon;
|
found_mime_type = cur->after_colon;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DEBUG)
|
|
||||||
bb_error_msg("sending file '%s' content-type: %s",
|
|
||||||
url, found_mime_type);
|
|
||||||
|
|
||||||
f = open(url, O_RDONLY);
|
|
||||||
if (f < 0) {
|
|
||||||
if (DEBUG)
|
|
||||||
bb_perror_msg("can't open '%s'", url);
|
|
||||||
/* Error pages are sent by using send_file_and_exit(SEND_BODY).
|
|
||||||
* IOW: it is unsafe to call send_headers_and_exit
|
|
||||||
* if what is SEND_BODY! Can recurse! */
|
|
||||||
if (what != SEND_BODY)
|
|
||||||
send_headers_and_exit(HTTP_NOT_FOUND);
|
|
||||||
log_and_exit();
|
|
||||||
}
|
}
|
||||||
#if ENABLE_FEATURE_HTTPD_RANGES
|
#if ENABLE_FEATURE_HTTPD_RANGES
|
||||||
if (what == SEND_BODY)
|
if (what == SEND_BODY)
|
||||||
@ -1596,9 +1565,9 @@ static void send_file_and_exit(const char *url, int what)
|
|||||||
range_end = file_size - 1;
|
range_end = file_size - 1;
|
||||||
}
|
}
|
||||||
if (range_end < range_start
|
if (range_end < range_start
|
||||||
|| lseek(f, range_start, SEEK_SET) != range_start
|
|| lseek(fd, range_start, SEEK_SET) != range_start
|
||||||
) {
|
) {
|
||||||
lseek(f, 0, SEEK_SET);
|
lseek(fd, 0, SEEK_SET);
|
||||||
range_start = 0;
|
range_start = 0;
|
||||||
} else {
|
} else {
|
||||||
range_len = range_end - range_start + 1;
|
range_len = range_end - range_start + 1;
|
||||||
@ -1607,43 +1576,42 @@ static void send_file_and_exit(const char *url, int what)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (what & SEND_HEADERS)
|
if (what & SEND_HEADERS)
|
||||||
send_headers(HTTP_OK);
|
send_headers(HTTP_OK);
|
||||||
|
|
||||||
#if ENABLE_FEATURE_HTTPD_USE_SENDFILE
|
#if ENABLE_FEATURE_HTTPD_USE_SENDFILE
|
||||||
offset = range_start;
|
{
|
||||||
do {
|
off_t offset = range_start;
|
||||||
|
while (1) {
|
||||||
/* sz is rounded down to 64k */
|
/* sz is rounded down to 64k */
|
||||||
ssize_t sz = MAXINT(ssize_t) - 0xffff;
|
ssize_t sz = MAXINT(ssize_t) - 0xffff;
|
||||||
USE_FEATURE_HTTPD_RANGES(if (sz > range_len) sz = range_len;)
|
USE_FEATURE_HTTPD_RANGES(if (sz > range_len) sz = range_len;)
|
||||||
count = sendfile(1, f, &offset, sz);
|
count = sendfile(STDOUT_FILENO, fd, &offset, sz);
|
||||||
if (count < 0) {
|
if (count < 0) {
|
||||||
if (offset == range_start)
|
if (offset == range_start)
|
||||||
goto fallback;
|
break; /* fall back to read/write loop */
|
||||||
goto fin;
|
goto fin;
|
||||||
}
|
}
|
||||||
USE_FEATURE_HTTPD_RANGES(range_len -= sz;)
|
USE_FEATURE_HTTPD_RANGES(range_len -= sz;)
|
||||||
} while (count > 0 && range_len);
|
if (count == 0 || range_len == 0)
|
||||||
log_and_exit();
|
log_and_exit();
|
||||||
|
}
|
||||||
fallback:
|
}
|
||||||
#endif
|
#endif
|
||||||
while ((count = safe_read(f, iobuf, IOBUF_SIZE)) > 0) {
|
while ((count = safe_read(fd, iobuf, IOBUF_SIZE)) > 0) {
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
USE_FEATURE_HTTPD_RANGES(if (count > range_len) count = range_len;)
|
USE_FEATURE_HTTPD_RANGES(if (count > range_len) count = range_len;)
|
||||||
n = full_write(STDOUT_FILENO, iobuf, count);
|
n = full_write(STDOUT_FILENO, iobuf, count);
|
||||||
if (count != n)
|
if (count != n)
|
||||||
break;
|
break;
|
||||||
USE_FEATURE_HTTPD_RANGES(range_len -= count;)
|
USE_FEATURE_HTTPD_RANGES(range_len -= count;)
|
||||||
if (!range_len)
|
if (range_len == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if ENABLE_FEATURE_HTTPD_USE_SENDFILE
|
if (count < 0) {
|
||||||
fin:
|
USE_FEATURE_HTTPD_USE_SENDFILE(fin:)
|
||||||
#endif
|
if (verbose > 1)
|
||||||
if (count < 0 && verbose > 1)
|
|
||||||
bb_perror_msg("error");
|
bb_perror_msg("error");
|
||||||
|
}
|
||||||
log_and_exit();
|
log_and_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2199,10 +2167,8 @@ static void mini_httpd(int server_socket)
|
|||||||
|
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
/* child */
|
/* child */
|
||||||
#if ENABLE_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP
|
|
||||||
/* Do not reload config on HUP */
|
/* Do not reload config on HUP */
|
||||||
signal(SIGHUP, SIG_IGN);
|
signal(SIGHUP, SIG_IGN);
|
||||||
#endif
|
|
||||||
close(server_socket);
|
close(server_socket);
|
||||||
xmove_fd(n, 0);
|
xmove_fd(n, 0);
|
||||||
xdup2(0, 1);
|
xdup2(0, 1);
|
||||||
@ -2244,10 +2210,8 @@ static void mini_httpd_nommu(int server_socket, int argc, char **argv)
|
|||||||
|
|
||||||
if (vfork() == 0) {
|
if (vfork() == 0) {
|
||||||
/* child */
|
/* child */
|
||||||
#if ENABLE_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP
|
|
||||||
/* Do not reload config on HUP */
|
/* Do not reload config on HUP */
|
||||||
signal(SIGHUP, SIG_IGN);
|
signal(SIGHUP, SIG_IGN);
|
||||||
#endif
|
|
||||||
close(server_socket);
|
close(server_socket);
|
||||||
xmove_fd(n, 0);
|
xmove_fd(n, 0);
|
||||||
xdup2(0, 1);
|
xdup2(0, 1);
|
||||||
@ -2278,13 +2242,10 @@ static void mini_httpd_inetd(void)
|
|||||||
handle_incoming_and_exit(&fromAddr);
|
handle_incoming_and_exit(&fromAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP
|
static void sighup_handler(int sig UNUSED_PARAM)
|
||||||
static void sighup_handler(int sig)
|
|
||||||
{
|
{
|
||||||
parse_conf(default_path_httpd_conf, sig ? SIGNALED_PARSE : FIRST_PARSE);
|
parse_conf(default_path_httpd_conf, SIGNALED_PARSE);
|
||||||
signal_SA_RESTART_empty_mask(SIGHUP, sighup_handler);
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
c_opt_config_file = 0,
|
c_opt_config_file = 0,
|
||||||
@ -2395,7 +2356,7 @@ int httpd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 /*was #if ENABLE_FEATURE_HTTPD_CGI*/
|
#if 0
|
||||||
/* User can do it himself: 'env - PATH="$PATH" httpd'
|
/* User can do it himself: 'env - PATH="$PATH" httpd'
|
||||||
* We don't do it because we don't want to screw users
|
* We don't do it because we don't want to screw users
|
||||||
* which want to do
|
* which want to do
|
||||||
@ -2413,15 +2374,9 @@ int httpd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLE_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP
|
|
||||||
if (!(opt & OPT_INETD)) {
|
|
||||||
/* runs parse_conf() inside */
|
|
||||||
sighup_handler(0);
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
parse_conf(default_path_httpd_conf, FIRST_PARSE);
|
parse_conf(default_path_httpd_conf, FIRST_PARSE);
|
||||||
}
|
if (!(opt & OPT_INETD))
|
||||||
|
signal(SIGHUP, sighup_handler);
|
||||||
|
|
||||||
xfunc_error_retval = 0;
|
xfunc_error_retval = 0;
|
||||||
if (opt & OPT_INETD)
|
if (opt & OPT_INETD)
|
||||||
|
@ -632,11 +632,9 @@ CONFIG_HOSTNAME=y
|
|||||||
CONFIG_HTTPD=y
|
CONFIG_HTTPD=y
|
||||||
CONFIG_FEATURE_HTTPD_RANGES=y
|
CONFIG_FEATURE_HTTPD_RANGES=y
|
||||||
CONFIG_FEATURE_HTTPD_USE_SENDFILE=y
|
CONFIG_FEATURE_HTTPD_USE_SENDFILE=y
|
||||||
CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP=y
|
|
||||||
CONFIG_FEATURE_HTTPD_SETUID=y
|
CONFIG_FEATURE_HTTPD_SETUID=y
|
||||||
CONFIG_FEATURE_HTTPD_BASIC_AUTH=y
|
CONFIG_FEATURE_HTTPD_BASIC_AUTH=y
|
||||||
CONFIG_FEATURE_HTTPD_AUTH_MD5=y
|
CONFIG_FEATURE_HTTPD_AUTH_MD5=y
|
||||||
CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES=y
|
|
||||||
CONFIG_FEATURE_HTTPD_CGI=y
|
CONFIG_FEATURE_HTTPD_CGI=y
|
||||||
CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR=y
|
CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR=y
|
||||||
CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV=y
|
CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV=y
|
||||||
|
Loading…
x
Reference in New Issue
Block a user