Date: Wed, 28 Jun 2000 16:40:03 -0700 (PDT) From: Kelly Yancey <kbyanc@posi.net> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/19514: patch to prevent tail'ing directories Message-ID: <200006282340.QAA32963@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/19514; it has been noted by GNATS.
From: Kelly Yancey <kbyanc@posi.net>
To: Bruce Evans <bde@zeta.org.au>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/19514: patch to prevent tail'ing directories
Date: Wed, 28 Jun 2000 19:32:53 -0400 (EDT)
On Tue, 27 Jun 2000, Bruce Evans wrote:
> POSIX.2 (in the old draft that I have) specifically requires "tail -c"
> to accept arbitrary data. tail(1) without -c is only required to handle
> text files. head(1) is only required to handle text files. cat(1) is
> required to handle all types of files.
>
I just researched this in the SUS and found the same thing. So contrary
to my previous post, do not close this PR yet. Instead, please apply the
following patch instead. It keeps us SUS and POSIX compliant in this
regards, but is still 'user-friendly'.
Index: usr.bin/tail/tail.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tail/tail.c,v
retrieving revision 1.6
diff -u -r1.6 tail.c
--- usr.bin/tail/tail.c 1999/07/04 17:26:03 1.6
+++ usr.bin/tail/tail.c 2000/06/28 23:23:24
@@ -69,7 +69,7 @@
FILE *fp;
long off;
enum STYLE style;
- int ch, first;
+ int ch, first, num;
char *p;
/*
@@ -164,6 +164,7 @@
}
}
+ num = 0;
if (*argv)
for (first = 1; fname = *argv++;) {
if ((fp = fopen(fname, "r")) == NULL ||
@@ -171,7 +172,25 @@
ierr();
continue;
}
- if (argc > 1) {
+ if (style == FLINES || style == RLINES) {
+ /*
+ * SUS says that `line' mode is only required
+ * to support text files. We support everything
+ * that `makes sense'.
+ */
+ if (S_ISDIR(sb.st_mode)) {
+ warnx("%s is a directory", fname);
+ continue;
+ } else if (S_ISLNK(sb.st_mode)) {
+ warnx("%s is a symlink", fname);
+ continue;
+ } else if (S_ISWHT(sb.st_mode)) {
+ warnx("%s is a whiteout entry", fname);
+ continue;
+ }
+ }
+ num++;
+ if (num > 1) {
(void)printf("%s==> %s <==\n",
first ? "" : "\n", fname);
first = 0;
Thanks,
Kelly
--
Kelly Yancey - kbyanc@posi.net - Belmont, CA
System Administrator, eGroups.com http://www.egroups.com/
Maintainer, BSD Driver Database http://www.posi.net/freebsd/drivers/
Coordinator, Team FreeBSD http://www.posi.net/freebsd/Team-FreeBSD/
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200006282340.QAA32963>
