| 95 | } |
| 96 | |
| 97 | static apr_status_t ap_cgi_build_command(const char **cmd, const char ***argv, |
| 98 | request_rec *r, apr_pool_t *p, |
| 99 | cgi_exec_info_t *e_info) |
| 100 | { |
| 101 | char *ext = NULL; |
| 102 | char *cmd_only, *ptr; |
| 103 | const char *new_cmd; |
| 104 | netware_dir_config *d; |
| 105 | const char *args = ""; |
| 106 | |
| 107 | d = (netware_dir_config *)ap_get_module_config(r->per_dir_config, |
| 108 | &netware_module); |
| 109 | |
| 110 | if (e_info->process_cgi) { |
| 111 | /* Handle the complete file name, we DON'T want to follow suexec, since |
| 112 | * an unrooted command is as predictable as shooting craps in Win32. |
| 113 | * |
| 114 | * Notice that unlike most mime extension parsing, we have to use the |
| 115 | * win32 parsing here, therefore the final extension is the only one |
| 116 | * we will consider |
| 117 | */ |
| 118 | *cmd = r->filename; |
| 119 | if (r->args && r->args[0] && !ap_strchr_c(r->args, '=')) { |
| 120 | args = r->args; |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | cmd_only = apr_pstrdup(p, *cmd); |
| 125 | e_info->cmd_type = APR_PROGRAM; |
| 126 | |
| 127 | /* truncate any arguments from the cmd */ |
| 128 | for (ptr = cmd_only; *ptr && (*ptr != ' '); ptr++); |
| 129 | *ptr = '\0'; |
| 130 | |
| 131 | /* Figure out what the extension is so that we can match it. */ |
| 132 | ext = strrchr(apr_filepath_name_get(cmd_only), '.'); |
| 133 | |
| 134 | /* If there isn't an extension then give it an empty string */ |
| 135 | if (!ext) { |
| 136 | ext = ""; |
| 137 | } |
| 138 | |
| 139 | /* eliminate the '.' if there is one */ |
| 140 | if (*ext == '.') { |
| 141 | ++ext; |
| 142 | } |
| 143 | |
| 144 | /* check if we have a registered command for the extension*/ |
| 145 | new_cmd = apr_table_get(d->file_type_handlers, ext); |
| 146 | e_info->detached = 1; |
| 147 | if (new_cmd == NULL) { |
| 148 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02135) |
| 149 | "Could not find a command associated with the %s extension", ext); |
| 150 | return APR_EBADF; |
| 151 | } |
| 152 | if (stricmp(new_cmd, "OS")) { |
| 153 | /* If we have a registered command then add the file that was passed in as a |
| 154 | parameter to the registered command. */ |
nothing calls this directly
no test coverage detected