| 2114 | }; |
| 2115 | |
| 2116 | static int create_uncompress_child(struct uncompress_parms *parm, apr_pool_t *cntxt, |
| 2117 | apr_file_t **pipe_in) |
| 2118 | { |
| 2119 | int rc = 1; |
| 2120 | const char *new_argv[4]; |
| 2121 | request_rec *r = parm->r; |
| 2122 | apr_pool_t *child_context = cntxt; |
| 2123 | apr_procattr_t *procattr; |
| 2124 | apr_proc_t *procnew; |
| 2125 | |
| 2126 | /* XXX missing 1.3 logic: |
| 2127 | * |
| 2128 | * what happens when !compr[parm->method].silent? |
| 2129 | * Should we create the err pipe, read it, and copy to the log? |
| 2130 | */ |
| 2131 | |
| 2132 | if ((apr_procattr_create(&procattr, child_context) != APR_SUCCESS) || |
| 2133 | (apr_procattr_io_set(procattr, APR_FULL_BLOCK, |
| 2134 | APR_FULL_BLOCK, APR_NO_PIPE) != APR_SUCCESS) || |
| 2135 | (apr_procattr_dir_set(procattr, |
| 2136 | ap_make_dirstr_parent(r->pool, r->filename)) != APR_SUCCESS) || |
| 2137 | (apr_procattr_cmdtype_set(procattr, APR_PROGRAM_PATH) != APR_SUCCESS)) { |
| 2138 | /* Something bad happened, tell the world. */ |
| 2139 | ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_ENOPROC, r, APLOGNO(01551) |
| 2140 | "couldn't setup child process: %s", r->filename); |
| 2141 | } |
| 2142 | else { |
| 2143 | new_argv[0] = compr[parm->method].argv[0]; |
| 2144 | new_argv[1] = compr[parm->method].argv[1]; |
| 2145 | new_argv[2] = r->filename; |
| 2146 | new_argv[3] = NULL; |
| 2147 | |
| 2148 | procnew = apr_pcalloc(child_context, sizeof(*procnew)); |
| 2149 | rc = apr_proc_create(procnew, compr[parm->method].argv[0], |
| 2150 | new_argv, NULL, procattr, child_context); |
| 2151 | |
| 2152 | if (rc != APR_SUCCESS) { |
| 2153 | /* Bad things happened. Everyone should have cleaned up. */ |
| 2154 | ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_ENOPROC, r, APLOGNO(01552) |
| 2155 | MODNAME ": could not execute `%s'.", |
| 2156 | compr[parm->method].argv[0]); |
| 2157 | } |
| 2158 | else { |
| 2159 | apr_pool_note_subprocess(child_context, procnew, APR_KILL_AFTER_TIMEOUT); |
| 2160 | *pipe_in = procnew->out; |
| 2161 | } |
| 2162 | } |
| 2163 | |
| 2164 | return (rc); |
| 2165 | } |
| 2166 | |
| 2167 | static int uncompress(request_rec *r, int method, |
| 2168 | unsigned char **newch, apr_size_t n) |
no test coverage detected