Project

General

Profile

Feature #2013 ยป lighttpd-e803990-xonly.diff

penma, 2009-06-25 18:43

View differences:

src/mod_cgi.c
53 53
typedef struct {
54 54
	array *cgi;
55 55
	unsigned short execute_all;
56
	unsigned short execute_x_only;
56 57
} plugin_config;
57 58

  
58 59
typedef struct {
......
167 168
#define PLUGIN_NAME "cgi"
168 169
#define CONFIG_ASSIGN      PLUGIN_NAME ".assign"
169 170
#define CONFIG_EXECUTE_ALL PLUGIN_NAME ".execute-all"
171
#define CONFIG_EXECUTE_X_ONLY PLUGIN_NAME ".execute-x-only"
170 172

  
171 173
SETDEFAULTS_FUNC(mod_cgi_set_defaults) {
172 174
	plugin_data *p = p_d;
......
175 177
	config_values_t cv[] = {
176 178
		{ CONFIG_ASSIGN,                 NULL, T_CONFIG_ARRAY,   T_CONFIG_SCOPE_CONNECTION },       /* 0 */
177 179
		{ CONFIG_EXECUTE_ALL,            NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION },       /* 1 */
180
		{ CONFIG_EXECUTE_X_ONLY,         NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION },       /* 2 */
178 181
		{ NULL,                          NULL, T_CONFIG_UNSET,   T_CONFIG_SCOPE_UNSET}
179 182
	};
180 183

  
......
190 193

  
191 194
		s->cgi    = array_init();
192 195
		s->execute_all = 0;
196
		s->execute_x_only = 0;
193 197

  
194 198
		cv[0].destination = s->cgi;
195 199
		cv[1].destination = &(s->execute_all);
200
		cv[2].destination = &(s->execute_x_only);
196 201

  
197 202
		p->config_storage[i] = s;
198 203

  
......
1017 1022

  
1018 1023
	PATCH_OPTION(cgi);
1019 1024
	PATCH_OPTION(execute_all);
1025
	PATCH_OPTION(execute_x_only);
1020 1026

  
1021 1027
	/* skip the first, the global context */
1022 1028
	for (i = 1; i < srv->config_context->used; i++) {
......
1034 1040
				PATCH_OPTION(cgi);
1035 1041
			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_EXECUTE_ALL))) {
1036 1042
				PATCH_OPTION(execute_all);
1043
			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_EXECUTE_X_ONLY))) {
1044
				PATCH_OPTION(execute_x_only);
1037 1045
			}
1038 1046
		}
1039 1047
	}
......
1061 1069

  
1062 1070
	if (HANDLER_ERROR == stat_cache_get_entry(srv, con, con->physical.path, &sce)) return HANDLER_GO_ON;
1063 1071
	if (!S_ISREG(sce->st.st_mode)) return HANDLER_GO_ON;
1072
	if (p->conf.execute_x_only == 1 && (sce->st.st_mode & S_IXOTH) == 0) return HANDLER_GO_ON;
1064 1073

  
1065 1074
	s_len = fn->used - 1;
1066 1075

  
    (1-1/1)