summaryrefslogtreecommitdiffstats
path: root/text-utils
diff options
context:
space:
mode:
authorSami Kerola2015-02-17 22:41:46 +0100
committerKarel Zak2015-03-05 10:31:18 +0100
commit9195eca64dcb9f25fec431fa24a3be6a8212b769 (patch)
treefc5dcd06212a83a7805bf0835febeab9121a0889 /text-utils
parenttailf: do not allow minus signed last lines argument (diff)
downloadkernel-qcow2-util-linux-9195eca64dcb9f25fec431fa24a3be6a8212b769.tar.gz
kernel-qcow2-util-linux-9195eca64dcb9f25fec431fa24a3be6a8212b769.tar.xz
kernel-qcow2-util-linux-9195eca64dcb9f25fec431fa24a3be6a8212b769.zip
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>
Diffstat (limited to 'text-utils')
-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 a89a3b531..e0c86a7ba 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);