From: Sami Kerola Date: Tue, 17 Feb 2015 21:41:46 +0000 (+0000) Subject: tailf: ensure file argument really is a file X-Git-Tag: v2.27-rc1~410 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9195eca64dcb9f25fec431fa24a3be6a8212b769;p=thirdparty%2Futil-linux.git 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 --- 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);