[mod_ssi] config ssi.exec (fixes #2051)

(thx benbrown)

x-ref:
  "mod_ssi Add configuration item to disable SSI exec."
  https://redmine.lighttpd.net/issues/2051
This commit is contained in:
Glenn Strauss 2016-04-13 19:50:31 -04:00
parent 6982b1930e
commit fa3a36ffd4
3 changed files with 12 additions and 0 deletions

1
NEWS
View File

@ -75,6 +75,7 @@ NEWS
* [core] define __STDC_WANT_LIB_EXT1__ (fixes #2722)
* [core] setrlimit max-fds <= rlim_max for non-root (fixes #2723)
* [mod_ssi] config ssi.conditional-requests
* [mod_ssi] config ssi.exec (fixes #2051)
- 1.4.39 - 2016-01-02
* [core] fix memset_s call (fixes #2698)

View File

@ -108,6 +108,7 @@ SETDEFAULTS_FUNC(mod_ssi_set_defaults) {
{ "ssi.extension", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION }, /* 0 */
{ "ssi.content-type", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 1 */
{ "ssi.conditional-requests", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 2 */
{ "ssi.exec", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 3 */
{ NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
};
@ -123,10 +124,12 @@ SETDEFAULTS_FUNC(mod_ssi_set_defaults) {
s->ssi_extension = array_init();
s->content_type = buffer_init();
s->conditional_requests = 0;
s->ssi_exec = 1;
cv[0].destination = s->ssi_extension;
cv[1].destination = s->content_type;
cv[2].destination = &(s->conditional_requests);
cv[3].destination = &(s->ssi_exec);
p->config_storage[i] = s;
@ -715,6 +718,10 @@ static int process_ssi_stmt(server *srv, connection *con, plugin_data *p, const
pid_t pid;
int from_exec_fds[2];
if (!p->conf.ssi_exec) { /* <!--#exec ... --> disabled by config */
break;
}
for (i = 2; i < n; i += 2) {
if (0 == strcmp(l[i], "cmd")) {
cmd = l[i+1];
@ -1123,6 +1130,7 @@ static int mod_ssi_patch_connection(server *srv, connection *con, plugin_data *p
PATCH(ssi_extension);
PATCH(content_type);
PATCH(conditional_requests);
PATCH(ssi_exec);
/* skip the first, the global context */
for (i = 1; i < srv->config_context->used; i++) {
@ -1142,6 +1150,8 @@ static int mod_ssi_patch_connection(server *srv, connection *con, plugin_data *p
PATCH(content_type);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssi.conditional-requests"))) {
PATCH(conditional_requests);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssi.exec"))) {
PATCH(ssi_exec);
}
}
}

View File

@ -18,6 +18,7 @@ typedef struct {
array *ssi_extension;
buffer *content_type;
unsigned short conditional_requests;
unsigned short ssi_exec;
} plugin_config;
typedef struct {