Skip to content

Conversation

@frgmntedflower
Copy link

@frgmntedflower frgmntedflower commented Jan 21, 2026

Fixes #10323

tail was checking path.exists() before attempting to open files.
This precheck returns false for any metadata error (including EACCES),
causing permission errors to be incorrectly reported as "No such file or directory".

Solution
Removed the exists() precheck. Now tail attempts to open the file directly,
which allows the OS to report the actual error (e.g., "Permission denied" for EACCES etc. ).

Testing
Tested with the reproduction steps from the issue, the build now reports:

$ ./target/debug/tail -n 1 /tmp/noexec/file
tail: cannot open '/tmp/noexec/file' for reading: Permission denied

Like the GNU tail:

$ tail -n 1 /tmp/noexec/file             
tail: cannot open '/tmp/noexec/file' for reading: Permission denied

I also made sure to run it against the testing suit, used fmt and clippy to check for any issues.
Hope that checks out!

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/tail/F-headers. tests/tail/F-headers is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/tail/F-vs-missing. tests/tail/F-vs-missing is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/tail/assert-2. tests/tail/assert-2 is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/tail/retry. tests/tail/retry is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/tail/wait. tests/tail/wait is passing on 'main'. Maybe you have to rebase?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tail: exists precheck masks permission errors

1 participant