1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-26 11:47:31 +00:00

Fix tail -f in capability mode.

We were not adding CAP_EVENT to input file capabilities, so kevent()
always failed with ENOTCAPABLE.  tail implements a fallback mode to
poll the file in this case, so the failure was not apparent.

Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D22709
This commit is contained in:
Mark Johnston 2019-12-06 23:39:38 +00:00
parent a6f21d15dd
commit eee07d30a0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=355470

View File

@ -93,11 +93,6 @@ main(int argc, char *argv[])
char *p;
cap_rights_t rights;
cap_rights_init(&rights, CAP_FSTAT, CAP_FSTATFS, CAP_FCNTL, CAP_MMAP_RW);
if (caph_rights_limit(STDIN_FILENO, &rights) < 0 ||
caph_limit_stderr() < 0 || caph_limit_stdout() < 0)
err(1, "can't limit stdio rights");
/*
* Tail's options are weird. First, -n10 is the same as -n-10, not
* -n+10. Second, the number options are 1 based and not offsets,
@ -167,6 +162,14 @@ main(int argc, char *argv[])
no_files = argc ? argc : 1;
cap_rights_init(&rights, CAP_FSTAT, CAP_FSTATFS, CAP_FCNTL,
CAP_MMAP_R);
if (fflag)
cap_rights_set(&rights, CAP_EVENT);
if (caph_rights_limit(STDIN_FILENO, &rights) < 0 ||
caph_limit_stderr() < 0 || caph_limit_stdout() < 0)
err(1, "can't limit stdio rights");
fa = fileargs_init(argc, argv, O_RDONLY, 0, &rights, FA_OPEN);
if (fa == NULL)
err(1, "unable to init casper");