On 08/18/22 11:53, Richard W.M. Jones wrote:
This is upstream in 5 commits 5764fa6f4..dd28b0054:
https://gitlab.com/nbdkit/nbdkit/-/commit/2620d95a4585204f0db0d55c0d41276d11... https://gitlab.com/nbdkit/nbdkit/-/commit/185e7d4010b353f36b5ca5d47467a770c5... https://gitlab.com/nbdkit/nbdkit/-/commit/17655b1ca67caa454e7a4ac83bc8c052b7... https://gitlab.com/nbdkit/nbdkit/-/commit/e7fdffde8142fb083625678b7a55455751... https://gitlab.com/nbdkit/nbdkit/-/commit/dd28b005430d020ccd1825437937c31733...
This also includes dirfd functionality and a rather complicated test for that. Turns out that bash refuses to open a directory as a file descriptor :-(
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