aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Kerola <kerolasa@iki.fi>2015-02-17 21:41:46 +0000
committerKarel Zak <kzak@redhat.com>2015-03-05 10:31:18 +0100
commit9195eca64dcb9f25fec431fa24a3be6a8212b769 (patch)
treefc5dcd06212a83a7805bf0835febeab9121a0889
parent16d3d9a04d5d2a7f4f10c3658cccc5aa0c7cd0af (diff)
downloadutil-linux-playground-9195eca64dcb9f25fec431fa24a3be6a8212b769.tar.gz
tailf: ensure file argument really is a file
The tailf(1) never worked very well with block or character devices, sockets, fifos and such. Now after mmap() is used to find last lines even the little command used to work for example pipes is broken, so test the tailf is asked to follow a file and when not fail. That said symlinks are OK, as long they point to a file. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
-rw-r--r--text-utils/tailf.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/text-utils/tailf.c b/text-utils/tailf.c
index a89a3b5315..e0c86a7ba4 100644
--- a/text-utils/tailf.c
+++ b/text-utils/tailf.c
@@ -276,7 +276,8 @@ int main(int argc, char **argv)
if (stat(filename, &st) != 0)
err(EXIT_FAILURE, _("stat of %s failed"), filename);
-
+ if (!S_ISREG(st.st_mode))
+ errx(EXIT_FAILURE, _("%s: is not a file"), filename);
if (st.st_size)
tailf(filename, lines, &st);