This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: O_EXEC and O_SEARCH
On Sat, Feb 23, 2013 at 12:01:39AM -0500, KOSAKI Motohiro wrote:
> > 1. Try to open with O_RDONLY. If it succeeds, we're done. This is
> > REALLY nice because it means O_SEARCH and O_EXEC "just work" even on
> > ancient or broken kernels as long as the target file is readable.
>
> Hmm..
> This algorithm seems slightly strange to me. Why do you want to try O_RDONLY at
> first?
> O_RDONLY require read permission and O_SEARCH, if i understand correctly,
> doesn't.
> I think you should try O_PATH at first.
If the file is readable, O_RDONLY will succeed and provides the
necessary semantics for O_EXEC and O_SEARCH. The only time O_EXEC or
O_SEARCH needs special support is when the file is not readable; these
modes were specifically designed for supporting that case.
Rich