| 1082 | /* execute process ********************************************************************************/ |
| 1083 | |
| 1084 | apr_status_t md_util_exec(apr_pool_t *p, const char *cmd, |
| 1085 | const char * const *argv, int *exit_code) |
| 1086 | { |
| 1087 | apr_status_t rv; |
| 1088 | apr_procattr_t *procattr; |
| 1089 | apr_proc_t *proc; |
| 1090 | apr_exit_why_e ewhy; |
| 1091 | char buffer[1024]; |
| 1092 | |
| 1093 | *exit_code = 0; |
| 1094 | if (!(proc = apr_pcalloc(p, sizeof(*proc)))) { |
| 1095 | return APR_ENOMEM; |
| 1096 | } |
| 1097 | if ( APR_SUCCESS == (rv = apr_procattr_create(&procattr, p)) |
| 1098 | && APR_SUCCESS == (rv = apr_procattr_io_set(procattr, APR_NO_FILE, |
| 1099 | APR_NO_PIPE, APR_FULL_BLOCK)) |
| 1100 | && APR_SUCCESS == (rv = apr_procattr_cmdtype_set(procattr, APR_PROGRAM_ENV)) |
| 1101 | && APR_SUCCESS == (rv = apr_proc_create(proc, cmd, argv, NULL, procattr, p))) { |
| 1102 | |
| 1103 | /* read stderr and log on INFO for possible fault analysis. */ |
| 1104 | while(APR_SUCCESS == (rv = apr_file_gets(buffer, sizeof(buffer)-1, proc->err))) { |
| 1105 | md_log_perror(MD_LOG_MARK, MD_LOG_INFO, 0, p, "cmd(%s) stderr: %s", cmd, buffer); |
| 1106 | } |
| 1107 | if (!APR_STATUS_IS_EOF(rv)) goto out; |
| 1108 | apr_file_close(proc->err); |
| 1109 | |
| 1110 | if (APR_CHILD_DONE == (rv = apr_proc_wait(proc, exit_code, &ewhy, APR_WAIT))) { |
| 1111 | /* let's not dwell on exit stati, but core should signal something's bad */ |
| 1112 | if (*exit_code > 127 || APR_PROC_SIGNAL_CORE == ewhy) { |
| 1113 | return APR_EINCOMPLETE; |
| 1114 | } |
| 1115 | return APR_SUCCESS; |
| 1116 | } |
| 1117 | } |
| 1118 | out: |
| 1119 | return rv; |
| 1120 | } |
| 1121 | |
| 1122 | /* base64 url encoding ****************************************************************************/ |
| 1123 |
no test coverage detected