From: William A. Rowe Jr Date: Thu, 21 Mar 2002 06:04:27 +0000 (+0000) Subject: Introduce earlier identification of command.com v.s. cmd.exe X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f57728a36aaf3900802786d7882306201c7de77;p=thirdparty%2Fapache%2Fhttpd.git Introduce earlier identification of command.com v.s. cmd.exe for Win32 .bat/.cmd scripts, and assure we treat command.com as a 16-bit application. [William Rowe] git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@94077 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/include/http_core.h b/src/include/http_core.h index 8ceaf730cff..feecb1d92ff 100644 --- a/src/include/http_core.h +++ b/src/include/http_core.h @@ -158,7 +158,7 @@ API_EXPORT(const array_header *) ap_requires (request_rec *); * CGI Script stuff for Win32... */ typedef enum { eFileTypeUNKNOWN, eFileTypeBIN, eFileTypeEXE16, eFileTypeEXE32, - eFileTypeSCRIPT } file_type_e; + eFileTypeSCRIPT, eCommandShell16, eCommandShell32 } file_type_e; typedef enum { INTERPRETER_SOURCE_UNSET, INTERPRETER_SOURCE_REGISTRY, INTERPRETER_SOURCE_SHEBANG } interpreter_source_e; API_EXPORT(file_type_e) ap_get_win32_interpreter(const request_rec *, char **); diff --git a/src/main/http_core.c b/src/main/http_core.c index 0e1a8f81278..d37b04bd83b 100644 --- a/src/main/http_core.c +++ b/src/main/http_core.c @@ -983,7 +983,7 @@ API_EXPORT (file_type_e) ap_get_win32_interpreter(const request_rec *r, { char *p, *shellcmd = getenv("COMSPEC"); if (!shellcmd) - shellcmd = SHELL_PATH; + return eFileTypeUNKNOWN; p = strchr(shellcmd, '\0'); if ((p - shellcmd >= 11) && !strcasecmp(p - 11, "command.com")) { @@ -992,14 +992,16 @@ API_EXPORT (file_type_e) ap_get_win32_interpreter(const request_rec *r, if (!strcasecmp(ext,".cmd")) return eFileTypeUNKNOWN; *interpreter = ap_pstrcat(r->pool, "\"", shellcmd, "\" /C %1", NULL); + return eCommandShell16; } - else + else { /* Assume any other likes long paths, and knows .cmd, * but the entire /c arg should be double quoted, e.g. * "c:\path\cmd.exe" /c ""prog" "arg" "arg"" */ *interpreter = ap_pstrcat(r->pool, "\"", shellcmd, "\" /C \"\"%1\" %*\"", NULL); - return eFileTypeSCRIPT; + return eCommandShell32; + } } /* If the file has an extension and it is not .com and not .exe and diff --git a/src/main/util_script.c b/src/main/util_script.c index 3fae2b54075..b69a03974ec 100644 --- a/src/main/util_script.c +++ b/src/main/util_script.c @@ -1126,7 +1126,7 @@ API_EXPORT(int) ap_call_exec(request_rec *r, child_info *pinfo, char *argv0, pEnvBlock, ap_make_dirstr_parent(r->pool, r->filename), &si, &pi)) { - if (fileType == eFileTypeEXE16) { + if (fileType == eFileTypeEXE16 || fileType == eCommandShell16) { /* Hack to get 16-bit CGI's working. It works for all the * standard modules shipped with Apache. pi.dwProcessId is 0 * for 16-bit CGIs and all the Unix specific code that calls