Changeset 1060

Show
Ignore:
Timestamp:
03/30/2006 06:01:37 AM (2 years ago)
Author:
moo
Message:

fixed #441

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/lighttpd-merge-1.4.x/src/proc_open.c

    r530 r1060  
    149149        BOOL procok; 
    150150        SECURITY_ATTRIBUTES security; 
    151         const char *shell; 
     151        const char *shell = NULL; 
     152        const char *windir = NULL; 
    152153        buffer *cmdline; 
    153154 
    154         if (NULL == (shell = getenv(SHELLENV))) { 
    155                 fprintf(stderr, "env %s is required", SHELLENV); 
     155        if (NULL == (shell = getenv(SHELLENV)) && 
     156                        NULL == (windir = getenv("SystemRoot")) && 
     157                        NULL == (windir = getenv("windir"))) { 
     158                fprintf(stderr, "One of %s,%%SystemRoot,%%windir is required", SHELLENV); 
    156159                return -1; 
    157160        } 
     
    178181 
    179182        cmdline = buffer_init(); 
    180         buffer_append_string(cmdline, shell); 
     183        if (shell) { 
     184                buffer_append_string(cmdline, shell); 
     185        } else { 
     186                buffer_append_string(cmdline, windir); 
     187                buffer_append_string(cmdline, "\\system32\\cmd.exe"); 
     188        } 
    181189        buffer_append_string_len(cmdline, CONST_STR_LEN(" /c ")); 
    182190        buffer_append_string(cmdline, command); 
    183191        procok = CreateProcess(NULL, cmdline->ptr, &security, &security, TRUE, 
    184192                        NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi); 
     193 
     194        if (FALSE == procok) { 
     195                fprintf(stderr, "failed to CreateProcess: %s", cmdline->ptr); 
     196                buffer_free(cmdline); 
     197                return -1; 
     198        } 
    185199        buffer_free(cmdline); 
    186  
    187         if (FALSE == procok) { 
    188                 fprintf(stderr, "failed to CreateProcess"); 
    189                 return -1; 
    190         } 
    191200 
    192201        proc->child = pi.hProcess; 
     
    227236 
    228237        if (NULL == (shell = getenv(SHELLENV))) { 
    229                 fprintf(stderr, "env %s is required", SHELLENV); 
    230                 return -1; 
     238                shell = "/bin/sh"; 
    231239        } 
    232240