Commit Graph

20 Commits

Author SHA1 Message Date
Mariusz Zaborski
c851fce6d7 tail: fix the checks if the file was rotated
The freopen(3) was replaced with fileargs_open(3) and fclose(3).
In the following function, we skip if the stream is standard in, so it is
safe to do so.
This also requires us to change the logic first to open the file and then
check its status. The stat(2) is disallowed in capability mode.

This commit unbrakes the -F option.
The bug was introduced in the r348708.

Reported by:	pho
Tested by:	pho
2019-06-09 22:55:21 +00:00
Pedro F. Giffuni
8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Warner Losh
fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Xin LI
dea85013f1 Use calloc() to get zeroed memory.
MFC after:	1 month
2013-01-08 22:14:45 +00:00
Joel Dahl
da52b4caaf Remove the advertising clause from UCB copyrighted files in usr.bin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change

Also add $FreeBSD$ to a few files to keep svn happy.

Discussed with:	imp, rwatson
2010-12-11 08:32:16 +00:00
Brian Somers
22da50cfc8 Change the behaviour of -F slightly; it now persists (forever) in
trying to open files rather than giving up when it encounters an
error.  ENOENT errors are not reported.

As a result, files that are moved away then recreated are not at
risk of being 'lost' to tail.  Files that are recreated and
temporarily have unreadable permissions will be shown when they
are fixed.

This behaviour is consistent with the GNU version of tail but
without the verbiage that goes with the GNU version.

This change also fixes error messages accompanying -f and -F.
They no longer report problems with (null)!

MFC after:	3 weeks
2009-06-05 09:08:53 +00:00
Tai-hwa Liang
e7356456ed Nuking the temporary pointer once it is properly tracked in local storage.
This should fix the double free() bug where there's no tailing newline(\n)
character:

	current# echo -n test | tail
	testAssertion failed: (run->magic == ARENA_RUN_MAGIC), function
	arena_dalloc, file /usr/src/lib/libc/stdlib/malloc.c, line 2448.
	Abort (core dumped)

Reviewed by:	kib
MFC after:	3 days
2007-11-22 01:51:46 +00:00
Philippe Charnier
f8c2d2bde1 initialize variables, WARNS=6 compliant 2007-11-02 18:06:51 +00:00
Konstantin Belousov
7ce8354a9b Fix various memory leaks.
Submitted by:	rdivacky
Obtained from:	OpenBSD
MFC after:	1 week
2007-10-17 09:52:08 +00:00
Paul Richards
4bba8e595e Convert to ANSI style function definitions. 2004-11-03 15:23:11 +00:00
Mark Murray
96b5910f32 Revert part of the last commit. This fixes tail for pipes.
Submitted by:	joerg
2003-06-10 16:49:14 +00:00
Mark Murray
814e3a92a9 WARNS=2 fixes, use __FBSDID(). 2001-12-12 00:01:16 +00:00
Jeroen Ruigrok van der Werven
48a1ef2284 Remove register keyword usage with prejudice.
Modern compilers are smarter when it comes to allocating register
usage.
2000-12-03 17:05:45 +00:00
Jeroen Ruigrok van der Werven
247e7cb1d3 Properly constify some static arrays.
Also #if out some sccsid's and add rcsid's.
2000-12-02 19:10:12 +00:00
Peter Wemm
c3fd5728c2 Dont forget to #include <err.h> 1996-08-25 21:14:19 +00:00
Peter Wemm
ac5512704d Argh! caught! *blush*.. This program was supplying it's own 'err' routine
which was slightly different to the libc one.  To save any more cunfusion,
use the libc one.
1996-08-25 21:12:01 +00:00
Adam David
6439f56e80 one file somehow slipped by me in the previous commit
tidy up
1996-07-30 15:44:30 +00:00
Adam David
49a598ab87 when file can be opened for read but cannot be read from:
fail once (was twice) in forward case
fail once (was no times) in reverse case

this can happen when file is a directory on an NFS or procfs mount.
1996-07-30 13:11:43 +00:00
Poul-Henning Kamp
f96ffb5acb Another program depending on zero'ed malloc.
Submitted by:	Kai Vorma <vode@snakemail.hut.fi>
1995-10-10 10:03:48 +00:00
Rodney W. Grimes
9b50d90275 BSD 4.4 Lite Usr.bin Sources 1994-05-27 12:33:43 +00:00