This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: O_EXEC and O_SEARCH


On Sat, Feb 23, 2013 at 12:05 AM, Rich Felker <dalias@aerifal.cx> wrote:
> 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.

Ah, ok. got it.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]