You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by TO...@aol.com on 1999/01/25 23:35:51 UTC
WIN32 CGI - CMD VS COMMAND - 2 OF 4
WIN32 PROBLEM: UNSAFE TO ALWAYS ASSUME 'COMMAND.COM' IF NOT NT
RELATES TO: Some currently open Apache WIN32 CGI PR REPORTS
The following is from the latest version of
..\APACHE_1.3.4\SRC\MAIN\UTIL_SCRIPT.C
My comments are all preceded with //:
The USC 'Berky-jerky' coding style has been re-organized
to make the code easier to follow...
API_EXPORT(int) ap_call_exec( request_rec *r,
child_info *pinfo,
char *argv0,
char **env,
int shellcmd
)
{
int pid = 0;
//: Top leg includes handling of all the RLIMIT_XXXX flags...
#ifdef OS2
//: OS2 handler is in this leg...
#elif defined(WIN32)
{
//: A lot of stack variables declared here...
//: None are relevant to this text...
if (!shellcmd)
{
//: Code in here only kicks in if 'shellcmd' not specified...
//: End if( !shellcmd )' pickup section...
}
if (shellcmd)
{
//: This pickup simply assumes that if 'GetVersionEx()' does
//: not specifically return 'VER_PLATFORM_WIN32_NT' then
//: COMMAND.COM should be versus CMD.EXE.
//: It is not sufficient to make this assumption for all
//: WIN32 executables just based on 'GetVersionEx()'.
//: Some evaluation of the target executable has to be
//: made and some consideration must be given to which
//: VERSION of WIN32 is active. WIN95 has a 16-bit
//: command shell which does not exist in WIN98 and may
//: or may not be present in WIN200x. WIN98 might have
//: Active Desktop and 'alternate command shells', etc. etc.
//: The only really safe thing to do is evaluate each specific
//: executable, compare it with each specific incarnation
//: of WIN32, and make the right decision based on all the
//: relevant variables.
//: Again... see the attached code from the USC TC5 project.
//: They are doing the same sort of thing and they seem to
//: have all the bases covered.
char *shell_cmd = "CMD.EXE /C ";
OSVERSIONINFO osver;
osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
/*
* Use CMD.EXE for NT, COMMAND.COM for WIN95
*/
if (GetVersionEx(&osver))
{
if (osver.dwPlatformId != VER_PLATFORM_WIN32_NT)
{
shell_cmd = "COMMAND.COM /C ";
}
}
pCommand = ap_pstrcat(r->pool, shell_cmd, argv0, NULL);
}
//: The rest...
return (pid);
}
}// End of ap_call_exec()...
// END OF DOCUMENT