Want support for O_DIRECTORY
POSIX 2008 (SUSv7) specifies the use of O_DIRECTORY:
The justification is here:
"In addition, the open() function refuses to open non-directories if the O_DIRECTORY flag is set. This avoids race conditions whereby a user might compromise the system by substituting a hard link to a sensitive file (e.g., a device or a FIFO) while a privileged application is running, where opening a file even for read access might have undesirable side-effects."
Apparently some software now depends on this, as reported to me by Sebastian Wiedenroth:
Some software (slibtool) recently started using O_DIRECTORY, which is how I noticed that it’s not yet available on illumos.
Looking further I found that you had already implemented support for it in illumos-core, it just never made it into the gate:
Indeed I have implemented this in illumos-core.
The code I have for this today does not allow O_CREAT and O_DIRECTORY be supplied together. The version of the specification I recall reading about this was a big vague about this. The 2018 version linked above is also still vague, but seems to suggest that it should be possible to use the two together with O_RDWR or O_WRONLY (presumably to create a directory). The version of the code I am planning to supply at first lacks this capability, and simply reports EINVAL if the two are used together.
It may be reasonable to refactor this slightly to add support so that O_DIRECTORY|O_CREAT|O_WR behaves like mkdir. Ideally I would like to do that in a follow up task if needed.
Updated by Robert Mustacchi over 1 year ago
I've tested this through the addition of the test suite and ran a couple of the other ones for good measure. Andy F. tested this with a bunch of third-party software that was previously being patched out. I also used truss on the test suite to verify it and verified that mandoc still worked with this.
Updated by Electric Monk over 1 year ago
- Status changed from New to Closed
- % Done changed from 90 to 100
commit 69c811ab73b7ce531454837ae68c4343e8724e0b Author: Robert Mustacchi <firstname.lastname@example.org> Date: 2020-02-01T06:34:51.000Z 9965 Want support for O_DIRECTORY Reviewed by: Andy Fiddaman <email@example.com> Reviewed by: Hans Rosenfeld <firstname.lastname@example.org> Approved by: Garrett D'Amore <email@example.com>