If log_input or log_output returns false, terminate the command.
This commit is contained in:
32
src/script.c
32
src/script.c
@@ -140,39 +140,49 @@ script_setup(uid_t uid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Call I/O plugin input method. */
|
/* Call I/O plugin input method. */
|
||||||
static void
|
static int
|
||||||
log_input(char *buf, unsigned int n)
|
log_input(char *buf, unsigned int n)
|
||||||
{
|
{
|
||||||
struct plugin_container *plugin;
|
struct plugin_container *plugin;
|
||||||
sigset_t omask;
|
sigset_t omask;
|
||||||
|
int rval = TRUE;
|
||||||
|
|
||||||
sigprocmask(SIG_BLOCK, &ttyblock, &omask);
|
sigprocmask(SIG_BLOCK, &ttyblock, &omask);
|
||||||
|
|
||||||
tq_foreach_fwd(&io_plugins, plugin) {
|
tq_foreach_fwd(&io_plugins, plugin) {
|
||||||
/* XXX - die if return != TRUE */
|
if (plugin->u.io->log_input) {
|
||||||
if (plugin->u.io->log_input)
|
if (!plugin->u.io->log_input(buf, n)) {
|
||||||
plugin->u.io->log_input(buf, n);
|
rval = FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sigprocmask(SIG_SETMASK, &omask, NULL);
|
sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||||
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call I/O plugin output method. */
|
/* Call I/O plugin output method. */
|
||||||
static void
|
static int
|
||||||
log_output(char *buf, unsigned int n)
|
log_output(char *buf, unsigned int n)
|
||||||
{
|
{
|
||||||
struct plugin_container *plugin;
|
struct plugin_container *plugin;
|
||||||
sigset_t omask;
|
sigset_t omask;
|
||||||
|
int rval = TRUE;
|
||||||
|
|
||||||
sigprocmask(SIG_BLOCK, &ttyblock, &omask);
|
sigprocmask(SIG_BLOCK, &ttyblock, &omask);
|
||||||
|
|
||||||
tq_foreach_fwd(&io_plugins, plugin) {
|
tq_foreach_fwd(&io_plugins, plugin) {
|
||||||
/* XXX - die if return != TRUE */
|
if (plugin->u.io->log_output) {
|
||||||
if (plugin->u.io->log_output)
|
if (!plugin->u.io->log_output(buf, n)) {
|
||||||
plugin->u.io->log_output(buf, n);
|
rval = FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sigprocmask(SIG_SETMASK, &omask, NULL);
|
sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||||
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -637,7 +647,8 @@ script_execve(struct command_details *details, char *argv[], char *envp[],
|
|||||||
} else {
|
} else {
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
break; /* got EOF */
|
break; /* got EOF */
|
||||||
log_input(input.buf + input.len, n);
|
if (!log_input(input.buf + input.len, n))
|
||||||
|
terminate_child(child, TRUE);
|
||||||
input.len += n;
|
input.len += n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -664,7 +675,8 @@ script_execve(struct command_details *details, char *argv[], char *envp[],
|
|||||||
} else {
|
} else {
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
break; /* got EOF */
|
break; /* got EOF */
|
||||||
log_output(output.buf + output.len, n);
|
if (!log_output(output.buf + output.len, n))
|
||||||
|
terminate_child(child, TRUE);
|
||||||
output.len += n;
|
output.len += n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user