Project

General

Profile

Feature #646 » path-elements.diff

path_elements diff with version 1.4.9 - melo, 2006-05-16 01:19

View differences:

src/mod_secure_download.c 2006-05-16 01:57:35.000000000 +0100
buffer *uri_prefix;
unsigned short timeout;
unsigned short path_elements;
} plugin_config;
typedef struct {
......
{ "secdownload.document-root", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 1 */
{ "secdownload.uri-prefix", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 2 */
{ "secdownload.timeout", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 3 */
{ "secdownload.path_elements", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 4 */
{ NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
};
......
s->doc_root = buffer_init();
s->uri_prefix = buffer_init();
s->timeout = 60;
s->path_elements = 0;
cv[0].destination = s->secret;
cv[1].destination = s->doc_root;
cv[2].destination = s->uri_prefix;
cv[3].destination = &(s->timeout);
cv[4].destination = &(s->path_elements);
p->config_storage[i] = s;
......
PATCH(doc_root);
PATCH(uri_prefix);
PATCH(timeout);
PATCH(path_elements);
/* skip the first, the global context */
for (i = 1; i < srv->config_context->used; i++) {
......
PATCH(uri_prefix);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("secdownload.timeout"))) {
PATCH(timeout);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("secdownload.path_elements"))) {
PATCH(path_elements);
}
}
}
......
plugin_data *p = p_d;
MD5_CTX Md5Ctx;
HASH HA1;
const char *rel_uri, *ts_str, *md5_str;
const char *rel_uri, *rel_uri_end, *ts_str, *md5_str;
time_t ts = 0;
size_t i;
size_t i, rel_uri_len, count;
if (con->uri.path->used == 0) return HANDLER_GO_ON;
......
}
rel_uri = ts_str + 8;
rel_uri_end = 0;
count = p->conf.path_elements;
if (count) {
rel_uri_end = rel_uri;
while (rel_uri_end && *rel_uri_end && count--) {
log_error_write(srv, __FILE__, __LINE__, "ss", "scanner is here: ", rel_uri_end);
rel_uri_end = strchr(rel_uri_end+1, '/');
}
}
if (rel_uri_end) {
log_error_write(srv, __FILE__, __LINE__, "ss", "full local_path: ", rel_uri);
log_error_write(srv, __FILE__, __LINE__, "ss", "discarding: ", rel_uri_end);
rel_uri_len = rel_uri_end - rel_uri;
}
else {
log_error_write(srv, __FILE__, __LINE__, "ss", "checking will be done with full local_path: ", rel_uri);
rel_uri_len = strlen(rel_uri);
}
/* checking MD5
*
......
*/
buffer_copy_string_buffer(p->md5, p->conf.secret);
buffer_append_string(p->md5, rel_uri);
buffer_append_string_len(p->md5, rel_uri, rel_uri_len);
buffer_append_string_len(p->md5, ts_str, 8);
MD5_Init(&Md5Ctx);
(1-1/2)