]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tailf: ensure file argument really is a file
authorSami Kerola <kerolasa@iki.fi>
Tue, 17 Feb 2015 21:41:46 +0000 (21:41 +0000)
committerKarel Zak <kzak@redhat.com>
Thu, 5 Mar 2015 09:31:18 +0000 (10:31 +0100)
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>
text-utils/tailf.c

index a89a3b531535ec2f20decb2b72afd2ba5a4ffdea..e0c86a7ba4ae8e1ede90eed1ec95c22d96ecc2f3 100644 (file)
@@ -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);