On 08/18/22 11:53, Richard W.M. Jones wrote:
This doesn't match my experience; for me, bash opens e.g. /tmp just fine
on both RHEL7 and Fedora35 -- but it must be a read-only open.
$ exec 9</tmp
[ok]
$ exec 9<>/tmp
bash: /tmp: Is a directory
The latter is actually expected; it comes from open(). See EISDIR at
<
https://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html>.
Commit dd28b005430d also adds
dfd = open (tmpdir, O_RDONLY | O_DIRECTORY);
where I think O_DIRECTORY is not strictly necessary (per spec, because
O_CREAT is absent, O_DIRECTORY only helps us refuse a non-directory --
but we do not expect such "attacks" here). So my take is that
O_DIRECTORY could be dropped from the C code, at which point a bash
redirection (read-only) should work just the same.
Laszlo