zeur here.

The following {,ab}use of tail(1):

% </var/log/messages tail -f

causes an abort trap 'cause of a missing "rpath" pledge. An excellent
demonstration of pledge(2)'s usefulness, since it exposed a little bug
that caused tail to try and re-open stdin, which is useless on
OpenBSD[0] (unless we parse stdin as "/dev/stdin" and its ino would
change -- unlikely).

The below patch fixes this by simply not trying to re-open stdin.

         --zeurkous.

[0] NetBSD, iirc, keeps track of the original path of opened files
    (other systems might too), but I suppose that's irrelevant here :)

Index: src/usr.bin/tail/forward.c
===================================================================
RCS file: /cvs/src/usr.bin/tail/forward.c,v
retrieving revision 1.31
diff -u -p -r1.31 forward.c
--- src/usr.bin/tail/forward.c  5 Jul 2016 05:06:27 -0000       1.31
+++ src/usr.bin/tail/forward.c  29 Dec 2018 05:42:07 -0000
@@ -221,7 +221,7 @@ forward(struct tailfile *tf, int nfiles,
                                         * a new file reappears with
                                         * the same name. 
                                         */
-                                       (void) tfreopen(ctf);
+                                       if(!is_stdin) (void)tfreopen(ctf);
                                } else if (ke.fflags & NOTE_TRUNCATE) {
                                        warnx("%s has been truncated, "
                                            "resetting.", ctf->fname);

Reply via email to