MCPcopy Create free account
hub / github.com/apache/httpd / ap_get_exec_line

Function ap_get_exec_line

server/util.c:3386–3426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3384}
3385
3386AP_DECLARE(char *) ap_get_exec_line(apr_pool_t *p,
3387 const char *cmd,
3388 const char * const * argv)
3389{
3390 char buf[MAX_STRING_LEN];
3391 apr_procattr_t *procattr;
3392 apr_proc_t *proc;
3393 apr_file_t *fp;
3394 apr_size_t nbytes = 1;
3395 char c;
3396 int k;
3397
3398 if (apr_procattr_create(&procattr, p) != APR_SUCCESS)
3399 return NULL;
3400 if (apr_procattr_io_set(procattr, APR_FULL_BLOCK, APR_FULL_BLOCK,
3401 APR_FULL_BLOCK) != APR_SUCCESS)
3402 return NULL;
3403 if (apr_procattr_dir_set(procattr,
3404 ap_make_dirstr_parent(p, cmd)) != APR_SUCCESS)
3405 return NULL;
3406 if (apr_procattr_cmdtype_set(procattr, APR_PROGRAM) != APR_SUCCESS)
3407 return NULL;
3408 proc = apr_pcalloc(p, sizeof(apr_proc_t));
3409 if (apr_proc_create(proc, cmd, argv, NULL, procattr, p) != APR_SUCCESS)
3410 return NULL;
3411 fp = proc->out;
3412
3413 if (fp == NULL)
3414 return NULL;
3415 /* XXX: we are reading 1 byte at a time here */
3416 for (k = 0; apr_file_read(fp, &c, &nbytes) == APR_SUCCESS
3417 && nbytes == 1 && (k < MAX_STRING_LEN-1) ; ) {
3418 if (c == '\n' || c == '\r')
3419 break;
3420 buf[k++] = c;
3421 }
3422 buf[k] = '\0';
3423 apr_file_close(fp);
3424
3425 return apr_pstrndup(p, buf, k);
3426}
3427
3428AP_DECLARE(int) ap_array_str_index(const apr_array_header_t *array,
3429 const char *s,

Callers 2

set_bind_passwordFunction · 0.85
set_crypto_passphraseFunction · 0.85

Calls 1

ap_make_dirstr_parentFunction · 0.85

Tested by

no test coverage detected