[server] add run_extcmd_write() call in code coverage mode
This commit is contained in:
parent
0c59f6e500
commit
a8879231c3
@ -554,7 +554,7 @@ _run_extcmd(uid_t uid, gid_t gid, const char *cmd, char *so_buf,
|
||||
int _run_extcmd_write(const char *cmd, const char *cmd_write, int *pid_status,
|
||||
const fko_srv_options_t * const opts)
|
||||
{
|
||||
int retval = EXTCMD_SUCCESS_ALL_OUTPUT;
|
||||
int retval = EXTCMD_SUCCESS_ALL_OUTPUT;
|
||||
char *argv_new[MAX_CMDLINE_ARGS]; /* for validation and/or execvpe() */
|
||||
int argc_new=0;
|
||||
|
||||
@ -588,7 +588,8 @@ int _run_extcmd_write(const char *cmd, const char *cmd_write, int *pid_status,
|
||||
|
||||
#if HAVE_EXECVPE
|
||||
if(opts->verbose > 1)
|
||||
log_msg(LOG_INFO, "run_extcmd_write() (with execvpe()): running CMD: %s", cmd);
|
||||
log_msg(LOG_INFO, "run_extcmd_write() (with execvpe()): running CMD: %s | %s",
|
||||
cmd_write, cmd);
|
||||
|
||||
if(pipe(pipe_fd) < 0)
|
||||
{
|
||||
@ -627,6 +628,10 @@ int _run_extcmd_write(const char *cmd, const char *cmd_write, int *pid_status,
|
||||
waitpid(pid, pid_status, 0);
|
||||
|
||||
#else
|
||||
if(opts->verbose > 1)
|
||||
log_msg(LOG_INFO, "run_extcmd_write() (without execvpe()): running CMD: %s | %s",
|
||||
cmd_write, cmd);
|
||||
|
||||
if ((fd = popen(cmd, "w")) == NULL)
|
||||
{
|
||||
log_msg(LOG_ERR, "Got popen error %i: %s", errno, strerror(errno));
|
||||
|
||||
@ -81,6 +81,17 @@ rule_exists_no_chk_support(const fko_srv_options_t * const opts,
|
||||
char port_search[CMD_BUFSIZE] = {0};
|
||||
char exp_ts_search[CMD_BUFSIZE] = {0};
|
||||
|
||||
#if CODE_COVERAGE
|
||||
int pid_status = 0;
|
||||
/* If we're maximizing code coverage, then exercise the run_extcmd_write()
|
||||
* function which is normally only used for the PF firewall. This is to
|
||||
* maximize code coverage in conjunction with the test suite, and is never
|
||||
* compiled in for a production release of fwknop.
|
||||
*/
|
||||
if(run_extcmd_write("/bin/grep -v test", "/bin/echo test", &pid_status, opts) != 0)
|
||||
log_msg(LOG_WARNING, "Code coverage: Could not execute command");
|
||||
#endif
|
||||
|
||||
snprintf(cmd_buf, CMD_BUFSIZE-1, "%s " IPT_LIST_RULES_ARGS,
|
||||
opts->fw_config->fw_command,
|
||||
fwc->table,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user