mirror of https://github.com/mkerrisk/man-pages
open.2: Note use of O_PATH to provide O_EXEC functionality
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
b9307a4a0b
commit
d1304ede08
18
man2/open.2
18
man2/open.2
|
@ -683,6 +683,24 @@ descriptor referring to the automount directory without triggering a mount.
|
|||
can then be used to determine if it is, in fact, an untriggered
|
||||
automount point
|
||||
.RB ( ".f_type == AUTOFS_SUPER_MAGIC" ).
|
||||
.IP
|
||||
One use of
|
||||
.B O_PATH
|
||||
for regular files is to provide the equivalent of POSIX.1's
|
||||
.B O_EXEC
|
||||
functionality.
|
||||
This permits us to open a file for which we have execute
|
||||
permission but not read permission, and then executing that file,
|
||||
with steps something like the following:
|
||||
.IP
|
||||
.in +4n
|
||||
.EX
|
||||
char buf[PATH_MAX];
|
||||
fd = open("some_prog", O_PATH);
|
||||
snprintf(buf, "/proc/self/fd/%d", fd);
|
||||
execl(buf, "some_prog", (char *) NULL);
|
||||
.EE
|
||||
.in
|
||||
.TP
|
||||
.B O_SYNC
|
||||
Write operations on the file will complete according to the requirements of
|
||||
|
|
Loading…
Reference in New Issue