MCPcopy Create free account
hub / github.com/apache/httpd / ap_cgi_build_command

Function ap_cgi_build_command

modules/arch/win32/mod_win32.c:369–538  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

367
368
369static apr_status_t ap_cgi_build_command(const char **cmd, const char ***argv,
370 request_rec *r, apr_pool_t *p,
371 cgi_exec_info_t *e_info)
372{
373 const apr_array_header_t *elts_arr = apr_table_elts(r->subprocess_env);
374 const apr_table_entry_t *elts = (apr_table_entry_t *) elts_arr->elts;
375 const char *ext = NULL;
376 const char *interpreter = NULL;
377 win32_dir_conf *d;
378 apr_file_t *fh;
379 const char *args = "";
380 int i;
381
382 d = (win32_dir_conf *)ap_get_module_config(r->per_dir_config,
383 &win32_module);
384
385 if (e_info->cmd_type) {
386 /* We have to consider that the client gets any QUERY_ARGS
387 * without any charset interpretation, use prep_string to
388 * create a string of the literal QUERY_ARGS bytes.
389 */
390 *cmd = r->filename;
391 if (r->args && r->args[0] && !ap_strchr_c(r->args, '=')) {
392 args = r->args;
393 }
394 }
395 /* Handle the complete file name, we DON'T want to follow suexec, since
396 * an unrooted command is as predictable as shooting craps in Win32.
397 * Notice that unlike most mime extension parsing, we have to use the
398 * win32 parsing here, therefore the final extension is the only one
399 * we will consider.
400 */
401 ext = strrchr(apr_filepath_name_get(*cmd), '.');
402
403 /* If the file has an extension and it is not .com and not .exe and
404 * we've been instructed to search the registry, then do so.
405 * Let apr_proc_create do all of the .bat/.cmd dirty work.
406 */
407 if (ext && (!strcasecmp(ext,".exe") || !strcasecmp(ext,".com")
408 || !strcasecmp(ext,".bat") || !strcasecmp(ext,".cmd"))) {
409 interpreter = "";
410 }
411 if (!interpreter && ext
412 && (d->script_interpreter_source
413 == INTERPRETER_SOURCE_REGISTRY
414 || d->script_interpreter_source
415 == INTERPRETER_SOURCE_REGISTRY_STRICT)) {
416 /* Check the registry */
417 int strict = (d->script_interpreter_source
418 == INTERPRETER_SOURCE_REGISTRY_STRICT);
419 interpreter = get_interpreter_from_win32_registry(r->pool, ext,
420 strict);
421 if (interpreter && e_info->cmd_type != APR_SHELLCMD) {
422 e_info->cmd_type = APR_PROGRAM_PATH;
423 }
424 else {
425 ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
426 strict ? APLOGNO(03180) "No ExecCGI verb found for files of type '%s'."

Callers

nothing calls this directly

Calls 6

ap_get_module_configFunction · 0.85
ap_strchr_cFunction · 0.85
split_argvFunction · 0.85
prep_stringFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected