Browse Source

use con->conf.server_tag in modules

do not expose server info server_tag is configured by admin

default con->conf.server_tag is still PACKAGE_DESC, those
admin can configure server.tag otherwise.

(these changes reduce recompilation and relinking when switching
 brances in source control)
personal/stbuehler/mod-csrf-old
Glenn Strauss 6 years ago
parent
commit
69ec5728f9
  1. 3
      src/configfile.c
  2. 8
      src/mod_cgi.c
  3. 4
      src/mod_dirlisting.c
  4. 9
      src/mod_fastcgi.c
  5. 9
      src/mod_scgi.c
  6. 3
      src/mod_ssi.c
  7. 11
      src/mod_status.c
  8. 5
      src/response.c

3
src/configfile.c

@ -9,6 +9,7 @@
#include "configfile.h"
#include "proc_open.h"
#include "request.h"
#include "version.h"
#include <sys/stat.h>
@ -206,7 +207,7 @@ static int config_insert(server *srv) {
s->ssl_ca_file = buffer_init();
s->error_handler = buffer_init();
s->error_handler_404 = buffer_init();
s->server_tag = buffer_init();
s->server_tag = buffer_init_string(PACKAGE_DESC);
s->ssl_cipher_list = buffer_init();
s->ssl_dh_file = buffer_init();
s->ssl_ec_curve = buffer_init();

8
src/mod_cgi.c

@ -36,8 +36,6 @@
#include <stdio.h>
#include <fcntl.h>
#include "version.h"
enum {EOL_UNSET, EOL_N, EOL_RN};
typedef struct {
@ -1087,11 +1085,7 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, handler_
env.size = 0;
env.used = 0;
if (buffer_is_empty(con->conf.server_tag)) {
cgi_env_add(&env, CONST_STR_LEN("SERVER_SOFTWARE"), CONST_STR_LEN(PACKAGE_DESC));
} else {
cgi_env_add(&env, CONST_STR_LEN("SERVER_SOFTWARE"), CONST_BUF_LEN(con->conf.server_tag));
}
cgi_env_add(&env, CONST_STR_LEN("SERVER_SOFTWARE"), CONST_BUF_LEN(con->conf.server_tag));
if (!buffer_string_is_empty(con->server_name)) {
size_t len = buffer_string_length(con->server_name);

4
src/mod_dirlisting.c

@ -33,8 +33,6 @@
#include <sys/extattr.h>
#endif
#include "version.h"
/* plugin config for all request/connections */
typedef struct {
@ -628,8 +626,6 @@ static void http_list_directory_footer(server *srv, connection *con, plugin_data
if (!buffer_string_is_empty(p->conf.set_footer)) {
buffer_append_string_buffer(out, p->conf.set_footer);
} else if (buffer_is_empty(con->conf.server_tag)) {
buffer_append_string_len(out, CONST_STR_LEN(PACKAGE_DESC));
} else {
buffer_append_string_buffer(out, con->conf.server_tag);
}

9
src/mod_fastcgi.c

@ -48,8 +48,6 @@
#include <sys/wait.h>
#endif
#include "version.h"
/*
*
* TODO:
@ -1961,12 +1959,7 @@ static int fcgi_create_env(server *srv, handler_ctx *hctx, int request_id) {
/* send FCGI_PARAMS */
buffer_string_prepare_copy(p->fcgi_env, 1023);
if (buffer_is_empty(con->conf.server_tag)) {
FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SERVER_SOFTWARE"), CONST_STR_LEN(PACKAGE_DESC)),con)
} else {
FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SERVER_SOFTWARE"), CONST_BUF_LEN(con->conf.server_tag)),con)
}
FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SERVER_SOFTWARE"), CONST_BUF_LEN(con->conf.server_tag)),con)
if (!buffer_is_empty(con->server_name)) {
size_t len = buffer_string_length(con->server_name);

9
src/mod_scgi.c

@ -37,8 +37,6 @@
# include <sys/wait.h>
#endif
#include "version.h"
enum {EOL_UNSET, EOL_N, EOL_RN};
/*
@ -1569,12 +1567,7 @@ static int scgi_create_env(server *srv, handler_ctx *hctx) {
scgi_env_add(p->scgi_env, CONST_STR_LEN("CONTENT_LENGTH"), buf, strlen(buf));
scgi_env_add(p->scgi_env, CONST_STR_LEN("SCGI"), CONST_STR_LEN("1"));
if (buffer_is_empty(con->conf.server_tag)) {
scgi_env_add(p->scgi_env, CONST_STR_LEN("SERVER_SOFTWARE"), CONST_STR_LEN(PACKAGE_DESC));
} else {
scgi_env_add(p->scgi_env, CONST_STR_LEN("SERVER_SOFTWARE"), CONST_BUF_LEN(con->conf.server_tag));
}
scgi_env_add(p->scgi_env, CONST_STR_LEN("SERVER_SOFTWARE"), CONST_BUF_LEN(con->conf.server_tag));
if (!buffer_is_empty(con->server_name)) {
size_t len = buffer_string_length(con->server_name);

3
src/mod_ssi.c

@ -40,7 +40,6 @@
#endif
#include "etag.h"
#include "version.h"
/* The newest modified time of included files for include statement */
static volatile time_t include_file_last_mtime = 0;
@ -205,7 +204,7 @@ static int build_ssi_cgi_vars(server *srv, connection *con, plugin_data *p) {
array_reset(p->ssi_cgi_env);
ssi_env_add(p->ssi_cgi_env, CONST_STRING("SERVER_SOFTWARE"), PACKAGE_DESC);
ssi_env_add(p->ssi_cgi_env, CONST_STRING("SERVER_SOFTWARE"), con->conf.server_tag->ptr);
ssi_env_add(p->ssi_cgi_env, CONST_STRING("SERVER_NAME"),
#ifdef HAVE_IPV6
inet_ntop(srv_sock->addr.plain.sa_family,

11
src/mod_status.c

@ -20,8 +20,6 @@
#include <time.h>
#include <stdio.h>
#include "version.h"
typedef struct {
buffer *config_url;
buffer *status_url;
@ -319,7 +317,9 @@ static handler_t mod_status_handle_server_status_html(server *srv, connection *c
/* connection listing */
buffer_append_string_len(b, CONST_STR_LEN("<h1>Server-Status (" PACKAGE_NAME " " PACKAGE_VERSION ")</h1>"));
buffer_append_string_len(b, CONST_STR_LEN("<h1>Server-Status ("));
buffer_append_string_buffer(b, con->conf.server_tag);
buffer_append_string_len(b, CONST_STR_LEN(")</h1>"));
buffer_append_string_len(b, CONST_STR_LEN("<table summary=\"status\" class=\"status\">"));
buffer_append_string_len(b, CONST_STR_LEN("<tr><td>Hostname</td><td class=\"string\">"));
@ -839,7 +839,10 @@ static handler_t mod_status_handle_server_config(server *srv, connection *con, v
" <title>Status</title>\n"
" </head>\n"
" <body>\n"
" <h1>" PACKAGE_DESC "</h1>\n"
" <h1>"));
buffer_append_string_buffer(b, con->conf.server_tag);
buffer_append_string_len(b, CONST_STR_LEN(
"</h1>\n"
" <table summary=\"status\" border=\"1\">\n"));
mod_status_header_append(b, "Server-Features");

5
src/response.c

@ -26,7 +26,6 @@
#include <stdio.h>
#include "sys-socket.h"
#include "version.h"
int http_response_write_header(server *srv, connection *con) {
buffer *b;
@ -109,9 +108,7 @@ int http_response_write_header(server *srv, connection *con) {
}
if (!have_server) {
if (buffer_is_empty(con->conf.server_tag)) {
buffer_append_string_len(b, CONST_STR_LEN("\r\nServer: " PACKAGE_DESC));
} else if (!buffer_string_is_empty(con->conf.server_tag)) {
if (!buffer_string_is_empty(con->conf.server_tag)) {
buffer_append_string_len(b, CONST_STR_LEN("\r\nServer: "));
buffer_append_string_encoded(b, CONST_BUF_LEN(con->conf.server_tag), ENCODING_HTTP_HEADER);
}

Loading…
Cancel
Save