mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-28 08:02:54 +00:00
When opening a trace file, open O_NONBLOCK so that ktrace doesn't stall
if the target is a fifo. After opening a trace file, check that it is a regular file, and if not, return an error. MFC after: 3 days Reported by: kris PR: 94278
This commit is contained in:
parent
945a519a23
commit
9e92c8d486
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=156715
@ -145,11 +145,14 @@ main(int argc, char *argv[])
|
||||
|
||||
omask = umask(S_IRWXG|S_IRWXO);
|
||||
if (append) {
|
||||
if ((fd = open(tracefile, O_CREAT | O_WRONLY, DEFFILEMODE)) < 0)
|
||||
if ((fd = open(tracefile, O_CREAT | O_WRONLY | O_NONBLOCK,
|
||||
DEFFILEMODE)) < 0)
|
||||
err(1, "%s", tracefile);
|
||||
if (fstat(fd, &sb) != 0 || sb.st_uid != getuid())
|
||||
errx(1, "refuse to append to %s not owned by you",
|
||||
tracefile);
|
||||
if (!(S_ISREG(sb.st_mode)))
|
||||
errx(1, "%s not regular file", tracefile);
|
||||
} else {
|
||||
if (unlink(tracefile) == -1 && errno != ENOENT)
|
||||
err(1, "unlink %s", tracefile);
|
||||
|
Loading…
Reference in New Issue
Block a user