SHA256
3
0
forked from pool/audit
audit/audit-445353.patch

51 lines
1.1 KiB
Diff

From: tonyj@suse.de
Date: Tue Nov 18 18:08:32 CET 2008
References: 445353
Upstream: no
Flush stdout if pipe. Prevents output being queued in pipebuf if input fails
to signal EOF.
--- audit-1.2.9/src/ausearch.c.old 2008-11-17 15:55:47.000000000 -0800
+++ audit-1.2.9/src/ausearch.c 2008-11-17 16:06:54.000000000 -0800
@@ -58,11 +58,11 @@
extern int match(llist *l);
extern void output_record(llist *l);
-static int input_is_pipe(void)
+static int is_pipe(int fd)
{
struct stat st;
- if (fstat(0, &st) == 0) {
+ if (fstat(fd, &st) == 0) {
if (S_ISFIFO(st.st_mode))
pipe_mode = 1;
}
@@ -92,7 +92,7 @@
rc = process_file(user_file);
else if (force_logs)
rc = process_logs();
- else if (input_is_pipe())
+ else if (is_pipe(0))
rc = process_stdin();
else
rc = process_logs();
@@ -175,6 +175,7 @@
{
llist entries; // entries in a record
int ret;
+ int flush = is_pipe(1);
/* For each record in file */
list_create(&entries);
@@ -185,6 +186,8 @@
}
if (match(&entries)) {
output_record(&entries);
+ if (flush)
+ fflush(stdout);
found = 1;
if (just_one) {
list_clear(&entries);