Project

General

Profile

Feature #1506 » mod_secure_download.patch

-- cyberline - Anonymous, 2008-01-09 10:22

View differences:

./src/mod_secure_download.c 2007-08-24 08:42:34.488077064 +0200
36 36
	buffer *doc_root;
37 37
	buffer *secret;
38 38
	buffer *uri_prefix;
39
	buffer *wrapper;
39 40

  
40 41
	unsigned short timeout;
41 42
} plugin_config;
......
76 77
			buffer_free(s->secret);
77 78
			buffer_free(s->doc_root);
78 79
			buffer_free(s->uri_prefix);
80
			buffer_free(s->wrapper);
79 81

  
80 82
			free(s);
81 83
		}
......
100 102
		{ "secdownload.document-root",     NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },       /* 1 */
101 103
		{ "secdownload.uri-prefix",        NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },       /* 2 */
102 104
		{ "secdownload.timeout",           NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },        /* 3 */
105
		{ "secdownload.wrapper",           NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },       /* 4 */
103 106
		{ NULL,                            NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
104 107
	};
105 108

  
......
115 118
		s->doc_root      = buffer_init();
116 119
		s->uri_prefix    = buffer_init();
117 120
		s->timeout       = 60;
121
		s->wrapper    	 = buffer_init();
118 122

  
119 123
		cv[0].destination = s->secret;
120 124
		cv[1].destination = s->doc_root;
121 125
		cv[2].destination = s->uri_prefix;
122 126
		cv[3].destination = &(s->timeout);
127
		cv[4].destination = s->wrapper;
123 128

  
124 129
		p->config_storage[i] = s;
125 130

  
......
165 170
	PATCH(secret);
166 171
	PATCH(doc_root);
167 172
	PATCH(uri_prefix);
173
	PATCH(wrapper);
168 174
	PATCH(timeout);
169 175

  
170 176
	/* skip the first, the global context */
......
187 193
				PATCH(uri_prefix);
188 194
			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("secdownload.timeout"))) {
189 195
				PATCH(timeout);
196
			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("secdownload.wrapper"))) {
197
				PATCH(wrapper);
190 198
			}
191 199
		}
192 200
	}
......
210 218

  
211 219
	if (buffer_is_empty(p->conf.uri_prefix)) return HANDLER_GO_ON;
212 220

  
221
	if (buffer_is_empty(p->conf.wrapper)) return HANDLER_GO_ON;
222

  
213 223
	if (buffer_is_empty(p->conf.secret)) {
214 224
		log_error_write(srv, __FILE__, __LINE__, "s",
215 225
				"secdownload.secret has to be set");
......
283 293
	buffer_copy_string_buffer(con->physical.doc_root, p->conf.doc_root);
284 294
	buffer_copy_string(con->physical.rel_path, rel_uri);
285 295
	buffer_copy_string_buffer(con->physical.path, con->physical.doc_root);
296

  
297
	if (buffer_is_empty(p->conf.wrapper)) {
286 298
	buffer_append_string_buffer(con->physical.path, con->physical.rel_path);
299
	} else {
300
		buffer_append_string_buffer(con->physical.path, p->conf.wrapper);
301
	        buffer_copy_string(con->uri.query, rel_uri); 
302
	}
287 303

  
288 304
	return HANDLER_GO_ON;
289 305
}
(1-1/3)